This project is archived and is in readonly mode.

#4784 ✓committed
Jan De Poorter

Namespaced form rendering error

Reported by Jan De Poorter | June 7th, 2010 @ 02:09 PM | in 3.0.2

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

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>

Attachments

Pages