diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-30 11:15:07 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-30 11:23:47 -0300 |
commit | 0c070ae568767a2c8e9bdec49ab3a1a24f113382 (patch) | |
tree | 7e019d49da88a74d542c121e44313e62325a8ff7 /actionpack/lib/action_dispatch | |
parent | 2b12288139f9bad6cf6d058d93af66cdf598dda9 (diff) | |
parent | 3efd90ac5b15d376bc5780d08d6e07d5a2b50ff1 (diff) | |
download | rails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.tar.gz rails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.tar.bz2 rails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.zip |
Merge pull request #18251 from tjgrathwell/fix-polymorphic-routes-to-model
Fix form_for to work with objects that implement to_model
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index d9bd277d62..2e116ea9cd 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -247,7 +247,7 @@ module ActionDispatch args = [] model = record.to_model - name = if record.persisted? + name = if model.persisted? args << model model.model_name.singular_route_key else @@ -290,11 +290,12 @@ module ActionDispatch when Class @key_strategy.call record.model_name else - if record.persisted? - args << record.to_model - record.to_model.model_name.singular_route_key + model = record.to_model + if model.persisted? + args << model + model.model_name.singular_route_key else - @key_strategy.call record.to_model.model_name + @key_strategy.call model.model_name end end |