I have a problem due to scopes and the form_for helper in rails 3. The routes - file looks like this:
scope \"(/:tab)\" do
resources :article
end
>
I have found this to be a really irritating problem and have gotten around this for now with the following monkey patch. Generic like this, it's a little bid off as you're simply passing the entire bag of parameters to polymorphic_url which is what form_for uses under the hood to guess the route. A more concise approach would be to merge just the scope value.
My solution:
https://gist.github.com/1848467
module ActionDispatch
module Routing
module PolymorphicRoutes
def polymorphic_path(record_or_hash_or_array, options = {})
begin
polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
rescue Exception => e
polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path).merge(params.reject{|k,v| ["controller", "action"].include? k.to_s}))
end
end
end
end
end