diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-09-05 23:37:17 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-09-05 23:37:17 +0000 |
commit | a75d273ececd36221c58540c2872601d8ce17eab (patch) | |
tree | 9764a24b3c1e5cb903e2fc5a682f3a0ce5d043af /actionpack/lib | |
parent | bc41e8a4495590e8297c824f681532f9049cfa2e (diff) | |
download | rails-a75d273ececd36221c58540c2872601d8ce17eab.tar.gz rails-a75d273ececd36221c58540c2872601d8ce17eab.tar.bz2 rails-a75d273ececd36221c58540c2872601d8ce17eab.zip |
Allow additional parameters to be passed to named route helpers when using positional arguments. Closes #8930 [ian.w.white@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 654727020a..2565a6dc3c 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -1160,10 +1160,17 @@ module ActionController # instead of # # foo_url(:bar => bar, :baz => baz, :bang => bang) - args.zip(#{segment_keys.inspect}).inject({}) do |h, (v, k)| + # + # Also allow options hash, so you can do + # + # foo_url(bar, baz, bang, :sort_by => 'baz') + # + options = args.last.is_a?(Hash) ? args.pop : {} + args = args.zip(#{segment_keys.inspect}).inject({}) do |h, (v, k)| h[k] = v h end + options.merge(args) end url_for(#{hash_access_method}(opts)) |