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.

Namespaced form rendering error

#4784

While migrating my app to Rails 3 I stumbled upon this problem

rendering a form with <%= render f %> in a namespaced controller (admin/clients/new.html.erb) raises the error "Missing partial admin/form with...". Problem seems to be the following line in partials.rb:

object.class.model_name.partial_path.dup.tap do |partial|
  path = @view.controller_path
  partial.insert(0, "#{File.dirname(path)}/") if path.include?(?/)
end

Which makes sense if object is a model where the associated partial_path is clients/client, where you actually want to render the admin/clients/_client partial. In this case however, we don't want admin/form, we want form prefixed with controller_path (which happens in find_template, btw). Suggested patch is adding a check if the partial itself has a / (so is a absolute path).

object.class.model_name.partial_path.dup.tap do |partial|
  path = @view.controller_path
  partial.insert(0, "#{File.dirname(path)}/") if partial.include?(?/) && path.include?(?/)
end

Patch including tests attached

Reported by Jan De Poorter · June 7th, 2010 @ 02:09 PM

State: committed
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Bruno Michel
    Bruno Michel

    +1 I've got the same bug on one of my app with Rails3.0.0.beta4, and the patch fixed it. I've seen no side effects or unexpected annoyances. The patch is also clean and has tests, so I think there is no reason to not apply it.

    June 9th, 2010 @ 05:55 PM

  2. Jan De Poorter
    Jan De Poorter
    • Assigned user set to José Valim

    June 14th, 2010 @ 09:46 AM

  3. José Valim
    José Valim
    • Milestone cleared.
    • State changed from new to open

    June 15th, 2010 @ 12:07 PM

  4. José Valim
    José Valim
    • State changed from open to committed

    June 20th, 2010 @ 11:05 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM