Just moved from 1.2 stable branch to 6959 to start using all of the
new resource changes. After a basic generate scaffold im getting a
RoutingError error on /merchants/1/edit:
ActionController::RoutingError: merchant_url failed to generate from
{:action=>"show", :controller=>"merchants",
:id=>[]}, expected:
{:action=>"show", :controller=>"merchants"}, diff:
{:id=>[]}
on this line: <% form_for(@merchant) do |f| %>
if I extrapolate it to the full form it works fine: <% form_for
:merchant, @merchant, :url => merchant_path(@merchant), :html => {
:method => :put, :class => "edit_merchant", :id =>
"edit_merchant_#{@merchant.id}" } do |f| %>
Looks like its because apply_form_for_options! in form_for explicitly
passes object as an array. I found a patch here (looks like someone
else noticed it too):
http://dev.rubyonrails.org/attachment/ticket/6432/form_helper_fix_redux.patch
Although Im not sure thats the correct place to correct it. I was
thinking either here (since its already using object and not
object_or_array in the rest of the method):
+++ vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
(working copy)
@@ -193,7 +193,7 @@
options[:html] ||= {}
options[:html].reverse_merge!(html_options)
- options[:url] ||= polymorphic_path(object_or_array)
+ options[:url] ||= polymorphic_path(object)
end
Or, take it a step further and correct it in polymorhic_url. Im just
not sure which one is correct and am just now digging into this code,
so I''ll leave it open to whoever knows what the proper fix would be.
For the time being I''ll just use my fix locally and keep an eye on the
ticket.
Joe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---