diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-26 00:50:46 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-26 00:50:46 -0700 |
commit | adb802e629f8d72afbb917575c9ed511a48a3d15 (patch) | |
tree | afe7c2abd8f2c4095dcbf057473271c2e6589151 /actionpack/lib/action_dispatch | |
parent | 8954ee650fbaa60a8766999f138557d5c8c12339 (diff) | |
parent | 3e67e45dc327631e085cc67aaa6522b44324364c (diff) | |
download | rails-adb802e629f8d72afbb917575c9ed511a48a3d15.tar.gz rails-adb802e629f8d72afbb917575c9ed511a48a3d15.tar.bz2 rails-adb802e629f8d72afbb917575c9ed511a48a3d15.zip |
Merge pull request #5581 from jamie/custom_param_field
Allow a defining custom member field on resources
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index cdc29fb304..20cdf67cf0 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -880,17 +880,18 @@ module ActionDispatch # CANONICAL_ACTIONS holds all actions that does not need a prefix or # a path appended since they fit properly in their scope level. VALID_ON_OPTIONS = [:new, :collection, :member] - RESOURCE_OPTIONS = [:as, :controller, :path, :only, :except] + RESOURCE_OPTIONS = [:as, :controller, :path, :only, :except, :param] CANONICAL_ACTIONS = %w(index create new show update destroy) class Resource #:nodoc: - attr_reader :controller, :path, :options + attr_reader :controller, :path, :options, :param def initialize(entities, options = {}) @name = entities.to_s @path = (options[:path] || @name).to_s @controller = (options[:controller] || @name).to_s @as = options[:as] + @param = options[:param] || :id @options = options end @@ -935,7 +936,7 @@ module ActionDispatch alias :collection_scope :path def member_scope - "#{path}/:id" + "#{path}/:#{param}" end def new_scope(new_path) @@ -943,7 +944,7 @@ module ActionDispatch end def nested_scope - "#{path}/:#{singular}_id" + "#{path}/:#{singular}_#{param}" end end |