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 07:40:41 -0700 |
commit | 5b6b0df8c585326266275b2fb25cfdfce924fe9b (patch) | |
tree | f4c3a2e75b707f876e03a7e1c10c0f38eef6b28e /actionpack/lib/action_dispatch | |
parent | b13d89ea9ee03467dc80a9ad29e3b10cece67b35 (diff) | |
parent | 537ede912895d421b24acfcbc86daf08f8f22157 (diff) | |
download | rails-5b6b0df8c585326266275b2fb25cfdfce924fe9b.tar.gz rails-5b6b0df8c585326266275b2fb25cfdfce924fe9b.tar.bz2 rails-5b6b0df8c585326266275b2fb25cfdfce924fe9b.zip |
Merge pull request #6588 from nbibler/polymorphic_to_model
Correct the use of to_model in polymorphic routing
Diffstat (limited to 'actionpack/lib/action_dispatch')
-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 013cf93dbc..055761fed5 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -97,7 +97,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 : @@ -124,6 +124,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 @@ -154,6 +156,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 |