This project is archived and is in readonly mode.
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
-
Bruno Michel June 9th, 2010 @ 05:55 PM
+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.
-
Jan De Poorter June 14th, 2010 @ 09:46 AM
- Assigned user set to José Valim
-
José Valim June 15th, 2010 @ 12:07 PM
- Milestone cleared.
- State changed from new to open
-
José Valim June 20th, 2010 @ 11:05 AM
- State changed from open to committed
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
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>