This project is archived and is in readonly mode.
Added a :style option for rendering partials with RecordIdentifier
Reported by Justin French | December 27th, 2008 @ 01:21 PM | in 2.x
Added a :style option for rendering partials with RecordIdentifier, allowing the same object to be rendered with a different partial to suit different rendering situations.
The value of :style is used to add a suffix to the standard partial name provided by RecordIdentifier#partial_path. Examples:
# Before:
<%= render :partial => "posts/post_summary", :locals => { :post => @post } %>
# After:
<%= render :partial => @post, :style => :summary %>
# Before:
<%= render :partial => "posts/post_summary", :collection => @posts, :as => :post %>
# After:
<%= render :partial => @posts, :style => :summary %>
This also heavily reduces the noisy view code if you want to use an alternate partial on a collection of objects with differing classes, like records from a table with STI.
Comments and changes to this ticket
-
DHH December 27th, 2008 @ 01:39 PM
- State changed from new to wontfix
I would almost think that the latest improvement to render would make this unneeded. See http://github.com/rails/rails/co...
You'd do your example as: <%= render("post_summary", :post => @post) %>. That seems just as long and doesn't require a special exception for :style.
-
Justin French December 27th, 2008 @ 01:55 PM
For the record, have been discussing this elsewhere. DHH's solution only solves one of the cases (not the collection version), but we're coming up with a plan B. Will leave this in wontfix.
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>