diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-13 11:45:27 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-13 11:45:27 -0600 |
commit | 521ef3c40f34d61d42d092eb39348a1be52ac57d (patch) | |
tree | 4dd08c40d4d4a829c085bf730a7420e68864cdac /actionpack/lib/action_dispatch/routing | |
parent | 01839834fd19e7be1e89309416bed497ac5ea0a0 (diff) | |
download | rails-521ef3c40f34d61d42d092eb39348a1be52ac57d.tar.gz rails-521ef3c40f34d61d42d092eb39348a1be52ac57d.tar.bz2 rails-521ef3c40f34d61d42d092eb39348a1be52ac57d.zip |
Passing in a crud action overloads the default action instead of creating a
new member action.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f7fb4ddd7a..e283cf0403 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -321,6 +321,8 @@ module ActionDispatch end module Resources + CRUD_ACTIONS = [:index, :show, :new, :edit, :create, :update, :destroy] + class Resource #:nodoc: attr_reader :plural, :singular @@ -489,8 +491,13 @@ module ActionDispatch end if args.first.is_a?(Symbol) - with_exclusive_name_prefix(args.first) do - return match("/#{args.first}(.:format)", options.merge(:to => args.first.to_sym)) + action = args.first + if CRUD_ACTIONS.include?(action) + return match("(.:format)", options.merge(:to => action)) + else + with_exclusive_name_prefix(action) do + return match("/#{action}(.:format)", options.merge(:to => action)) + end end end |