aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-05-03 23:26:54 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-05-04 15:17:04 -0300
commitd03aa104e069be4e301efa8cefb90a2a785a7bff (patch)
tree105d468d8067e80eedfe4fc796fb5730bf5d9b13 /actionpack/lib/action_dispatch/routing/mapper.rb
parent319db7b189fe1f02268c99c9e9566312535c02ec (diff)
downloadrails-d03aa104e069be4e301efa8cefb90a2a785a7bff.tar.gz
rails-d03aa104e069be4e301efa8cefb90a2a785a7bff.tar.bz2
rails-d03aa104e069be4e301efa8cefb90a2a785a7bff.zip
Force given path to http methods in mapper to skip canonical action checking
This fixes the following scenario: resources :contacts do post 'new', action: 'new', on: :collection, as: :new end Where the /new path is not generated because it's considered a canonical action, part of the normal resource actions: new_contacts POST /contacts(.:format) contacts#new Fixes #2999
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 4ea3937057..2a7d540517 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -535,7 +535,8 @@ module ActionDispatch
private
def map_method(method, args, &block)
options = args.extract_options!
- options[:via] = method
+ options[:via] = method
+ options[:path] ||= args.first if args.first.is_a?(String)
match(*args, options, &block)
self
end
@@ -1509,7 +1510,7 @@ module ActionDispatch
prefix = shallow_scoping? ?
"#{@scope[:shallow_path]}/#{parent_resource.path}/:id" : @scope[:path]
- path = if canonical_action?(action, path.blank?)
+ if canonical_action?(action, path.blank?)
prefix.to_s
else
"#{prefix}/#{action_path(action, path)}"