This project is archived and is in readonly mode.
Simplified render breaks with nested models (partials)
Reported by hmans | February 22nd, 2009 @ 04:44 PM
I have a namespaced resource, the model for which is Quiz::Question. In a view, I use the (awesome) new render syntax to render a question's partial (from app/views/quiz/questions/show.html.erb):
<%= render @question %>
Expecting this to resolve to app/views/quiz/questions/_question.html.erb. However, I'm getting the following error message:
Missing template quiz/quiz/questions/_question.erb in view path app/views
(Note the duplicate "quiz"!)
When I replace the call with the old-style render syntax, everything works fine (of course):
<%= render :partial => "quiz/questions/question", :object => @question %>
But obviously it'd be nicer to have the cool new render magic work. :-)
This is with current Edge Rails, revision ff1afbd65098643a06eef928f92fecf6e9d548b2.
Comments and changes to this ticket
-
DHH February 27th, 2009 @ 02:01 PM
- Assigned user set to josh
- Milestone cleared.
-
Andrew White February 27th, 2009 @ 03:08 PM
This is because in AC::RecordIdentifier.partial_path the controller_path is prepended to the tableized class name. Since your class name is namespaced under Quiz then you get File.join("quiz","quiz/questions/_question"). A workaround is to override the model_name class method and return an instance of AS::ModelName initialized with "Question" instead of the default "Quiz::Question"
Since there's an test for this behaviour I'm assuming that it's desired.
-
Repository March 7th, 2009 @ 08:05 PM
- State changed from new to resolved
(from [ea8488caef77cb8cf2031d344e74981ab6ea0e57]) Fixed simplified render with nested models [#2042 state:resolved] http://github.com/rails/rails/co...
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>
Tags
Referenced by
- 2042 Simplified render breaks with nested models (partials) (from [ea8488caef77cb8cf2031d344e74981ab6ea0e57]) Fixed s...