diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-06 15:45:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-12 15:54:43 -0700 |
commit | ad31afe63cb50372788e7c3aab15d73ba045a86f (patch) | |
tree | 60766721a2cac724366a3a5a19945784c76727f0 /actionpack/lib/action_dispatch | |
parent | a20cd8846397ed01c3a33f59f4f3ba039ec9bc23 (diff) | |
download | rails-ad31afe63cb50372788e7c3aab15d73ba045a86f.tar.gz rails-ad31afe63cb50372788e7c3aab15d73ba045a86f.tar.bz2 rails-ad31afe63cb50372788e7c3aab15d73ba045a86f.zip |
only pop records when we get an array
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 |