This project is archived and is in readonly mode.

#791 ✓resolved
Frederick Cheung

Add empty_template option when rendering a collection

Reported by Frederick Cheung | August 9th, 2008 @ 03:34 PM | in 2.x

I'm sick of writing

@@@ lang=ruby <% if search_results.empty? %> Nothing found <% else %> <%= render :partial => 'search_result', :collection => search_results %> <% end %>



As far as I'm concerned the less actual code  and branching in views, the better. Instead I propose

<%= render :partial => 'search_result', :collection => search_results, :empty_template => 'nothing_found' %>



With the nothing_found partial containing the obvious. (I'd rather have a better option name than empty_template but I haven't thought of one so far)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages