diff options
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 1a4adcbb35..192ab51db4 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -115,28 +115,29 @@ module ActionDispatch end record_list = record_or_hash_or_array.dup + record = record_list.pop when Hash unless record_or_hash_or_array[:id] raise ArgumentError, "Nil location provided. Can't build URI." end opts = record_or_hash_or_array.dup.merge!(opts) - record_list = [opts.delete(:id)] + record_list = [] + record = opts.delete(:id) when nil raise ArgumentError, "Nil location provided. Can't build URI." else - record_list = [record_or_hash_or_array] + record_list = [] + record = record_or_hash_or_array end - record = record_list.pop - inflection = lambda { |name| name.singular_route_key } should_pop = true - if record.try(:persisted?) + if options[:action] == 'new' + elsif record.try(:persisted?) should_pop = false - elsif options[:action] == 'new' else inflection = lambda { |name| name.route_key } end |