Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Simplified render breaks with nested models (partials)

#2042

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.

Reported by hmans · February 22nd, 2009 @ 04:44 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. DHH
    DHH
    • Assigned user set to josh
    • Milestone cleared.

    February 27th, 2009 @ 02:01 PM

  2. Andrew White
    Andrew White

    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.

    February 27th, 2009 @ 03:08 PM

  3. josh
    josh

    @hmans could you post some failing unit tests plz

    March 4th, 2009 @ 08:42 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [ea8488caef77cb8cf2031d344e74981ab6ea0e57]) Fixed simplified render with nested models [#2042 Simplified render breaks with nested models (partials) state:resolved] http://github.com/rails/rails/co...

    March 7th, 2009 @ 08:05 PM