diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-02 05:57:16 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-02 05:57:16 +0000 |
commit | fadaba679ac81aaab5c035bce61a369c1b33b1fe (patch) | |
tree | d4faccbfd7cba55ce1a5416a6b7711bc8f167ba0 /actionpack/lib | |
parent | 9e1d91c24bfd260df8609d5008fe40210f32cfd9 (diff) | |
download | rails-fadaba679ac81aaab5c035bce61a369c1b33b1fe.tar.gz rails-fadaba679ac81aaab5c035bce61a369c1b33b1fe.tar.bz2 rails-fadaba679ac81aaab5c035bce61a369c1b33b1fe.zip |
Introduce map.resources :cards, :as => 'tarjetas' to use a custom resource name in the URL: cards_path == '/tarjetas'. Closes #10578.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8785 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/resources.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 8ec6b84a53..52173bc8bb 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -44,13 +44,14 @@ module ActionController module Resources class Resource #:nodoc: attr_reader :collection_methods, :member_methods, :new_methods - attr_reader :path_prefix, :name_prefix + attr_reader :path_prefix, :name_prefix, :path_segment attr_reader :plural, :singular attr_reader :options def initialize(entities, options) @plural ||= entities @singular ||= options[:singular] || plural.to_s.singularize + @path_segment = options.delete(:as) || @plural @options = options @@ -75,7 +76,7 @@ module ActionController end def path - @path ||= "#{path_prefix}/#{plural}" + @path ||= "#{path_prefix}/#{path_segment}" end def new_path @@ -236,6 +237,13 @@ module ActionController # * <tt>:singular</tt> - specify the singular name used in the member routes. # * <tt>:requirements</tt> - set custom routing parameter requirements. # * <tt>:conditions</tt> - specify custom routing recognition conditions. Resources sets the :method value for the method-specific routes. + # * <tt>:as</tt> - specify a different resource name to use in the URL path. For example: + # # products_path == '/productos' + # map.resources :products, :as => 'productos' do |product| + # # product_reviews_path(product) == '/productos/1234/comentarios' + # product.resources :product_reviews, :as => 'comentarios' + # end + # # * <tt>:path_prefix</tt> - set a prefix to the routes with required route variables. # # Weblog comments usually belong to a post, so you might use resources like: |