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