diff options
author | José Valim <jose.valim@gmail.com> | 2012-06-01 07:40:41 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-06-01 16:42:09 +0200 |
commit | 5c565a294224911ba7b3929baabf3465172b40f0 (patch) | |
tree | 69cff5315c043708e48b866959be994f48b78893 /actionpack/lib | |
parent | 3449b757da669c08222be58b3743ff9ec48756cc (diff) | |
download | rails-5c565a294224911ba7b3929baabf3465172b40f0.tar.gz rails-5c565a294224911ba7b3929baabf3465172b40f0.tar.bz2 rails-5c565a294224911ba7b3929baabf3465172b40f0.zip |
Merge pull request #6588 from nbibler/polymorphic_to_model
Correct the use of to_model in polymorphic routing
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 8fde667108..86ce7a83b9 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -95,7 +95,7 @@ module ActionDispatch end record = extract_record(record_or_hash_or_array) - record = record.to_model if record.respond_to?(:to_model) + record = convert_to_model(record) args = Array === record_or_hash_or_array ? record_or_hash_or_array.dup : @@ -122,6 +122,8 @@ module ActionDispatch args.last.kind_of?(Hash) ? args.last.merge!(url_options) : args << url_options end + args.collect! { |a| convert_to_model(a) } + (proxy || self).send(named_route, *args) end @@ -152,6 +154,10 @@ module ActionDispatch options[:action] ? "#{options[:action]}_" : '' end + def convert_to_model(object) + object.respond_to?(:to_model) ? object.to_model : object + end + def routing_type(options) options[:routing_type] || :url end |