--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Creates named routes for implementing verb-oriented controllers for a collection resource.
- !ruby/struct:SM::Flow::P 
  body: "For example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  map.resources :messages\n"
- !ruby/struct:SM::Flow::P 
  body: "will map the following actions in the corresponding controller:"
- !ruby/struct:SM::Flow::VERB 
  body: "  class MessagesController &lt; ActionController::Base\n    # GET messages_url\n    def index\n      # return all messages\n    end\n\n    # GET new_message_url\n    def new\n      # return an HTML form for describing a new message\n    end\n\n    # POST messages_url\n    def create\n      # create a new message\n    end\n\n    # GET message_url(:id =&gt; 1)\n    def show\n      # find and return a specific message\n    end\n\n    # GET edit_message_url(:id =&gt; 1)\n    def edit\n      # return an HTML form for editing a specific message\n    end\n\n    # PUT message_url(:id =&gt; 1)\n    def update\n      # find and update a specific message\n    end\n\n    # DELETE message_url(:id =&gt; 1)\n    def destroy\n      # delete a specific message\n    end\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: "Along with the routes themselves, #resources generates named routes for use in controllers and views. <tt>map.resources :messages</tt> produces the following named routes and helpers:"
- !ruby/struct:SM::Flow::VERB 
  body: "  Named Route   Helpers\n  ============  =====================================================\n  messages      messages_url, hash_for_messages_url,\n                messages_path, hash_for_messages_path\n\n  message       message_url(id), hash_for_message_url(id),\n                message_path(id), hash_for_message_path(id)\n\n  new_message   new_message_url, hash_for_new_message_url,\n                new_message_path, hash_for_new_message_path\n\n  edit_message  edit_message_url(id), hash_for_edit_message_url(id),\n                edit_message_path(id), hash_for_edit_message_path(id)\n"
- !ruby/struct:SM::Flow::P 
  body: "You can use these helpers instead of #url_for or methods that take #url_for parameters. For example:"
- !ruby/struct:SM::Flow::VERB 
  body: "  redirect_to :controller =&gt; 'messages', :action =&gt; 'index'\n  # and\n  &lt;%= link_to &quot;edit this message&quot;, :controller =&gt; 'messages', :action =&gt; 'edit', :id =&gt; @message.id %&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: "now become:"
- !ruby/struct:SM::Flow::VERB 
  body: "  redirect_to messages_url\n  # and\n  &lt;%= link_to &quot;edit this message&quot;, edit_message_url(@message) # calls @message.id automatically\n"
- !ruby/struct:SM::Flow::P 
  body: "Since web browsers don't support the PUT and DELETE verbs, you will need to add a parameter '_method' to your form tags. The form helpers make this a little easier. For an update form with a <tt>@message</tt> object:"
- !ruby/struct:SM::Flow::VERB 
  body: "  &lt;%= form_tag message_path(@message), :method =&gt; :put %&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: or
- !ruby/struct:SM::Flow::VERB 
  body: "  &lt;% form_for :message, @message, :url =&gt; message_path(@message), :html =&gt; {:method =&gt; :put} do |f| %&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: "The #resources method accepts the following options to customize the resulting routes:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: "<tt>:collection</tt> - add named routes for other actions that operate on the collection. Takes a hash of <tt>#{action} =&gt; #{method}</tt>, where method is <tt>:get</tt>/<tt>:post</tt>/<tt>:put</tt>/<tt>:delete</tt> or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages/rss, with a route of rss_messages_url."
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:member</tt> - same as :collection, but for actions that operate on a specific member.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:new</tt> - same as :collection, but for actions that operate on the new resource action.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:controller</tt> - specify the controller name for the routes.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:singular</tt> - specify the singular name used in the member routes.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:requirements</tt> - set custom routing parameter requirements.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:conditions</tt> - specify custom routing recognition conditions. Resources sets the :method value for the method-specific routes.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:path_prefix</tt> - set a prefix to the routes with required route variables.
  - !ruby/struct:SM::Flow::P 
    body: "Weblog comments usually belong to a post, so you might use resources like:"
  - !ruby/struct:SM::Flow::VERB 
    body: "  map.resources :articles\n  map.resources :comments, :path_prefix =&gt; '/articles/:article_id'\n"
  - !ruby/struct:SM::Flow::P 
    body: "You can nest resources calls to set this automatically:"
  - !ruby/struct:SM::Flow::VERB 
    body: "  map.resources :articles do |article|\n    article.resources :comments\n  end\n"
  - !ruby/struct:SM::Flow::P 
    body: The comment resources work the same, but must now include a value for :article_id.
  - !ruby/struct:SM::Flow::VERB 
    body: "  article_comments_url(@article)\n  article_comment_url(@article, @comment)\n\n  article_comments_url(:article_id =&gt; @article)\n  article_comment_url(:article_id =&gt; @article, :id =&gt; @comment)\n"
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>:name_prefix</tt> - define a prefix for all generated routes, usually ending in an underscore. Use this if you have named routes that may clash.
  - !ruby/struct:SM::Flow::VERB 
    body: "  map.resources :tags, :path_prefix =&gt; '/books/:book_id', :name_prefix =&gt; 'book_'\n  map.resources :tags, :path_prefix =&gt; '/toys/:toy_id',   :name_prefix =&gt; 'toy_'\n"
  type: :BULLET
- !ruby/struct:SM::Flow::P 
  body: "You may also use :name_prefix to override the generic named routes in a nested resource:"
- !ruby/struct:SM::Flow::VERB 
  body: "  map.resources :articles do |article|\n    article.resources :comments, :name_prefix =&gt; nil\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: "This will yield named resources like so:"
- !ruby/struct:SM::Flow::VERB 
  body: "  comments_url(@article)\n  comment_url(@article, @comment)\n"
- !ruby/struct:SM::Flow::P 
  body: If <tt>map.resources</tt> is called with multiple resources, they all get the same options applied.
- !ruby/struct:SM::Flow::P 
  body: "Examples:"
- !ruby/struct:SM::Flow::VERB 
  body: "  map.resources :messages, :path_prefix =&gt; &quot;/thread/:thread_id&quot;\n  # --&gt; GET /thread/7/messages/1\n\n  map.resources :messages, :collection =&gt; { :rss =&gt; :get }\n  # --&gt; GET /messages/rss (maps to the #rss action)\n  #     also adds a named route called &quot;rss_messages&quot;\n\n  map.resources :messages, :member =&gt; { :mark =&gt; :post }\n  # --&gt; POST /messages/1/mark (maps to the #mark action)\n  #     also adds a named route called &quot;mark_message&quot;\n\n  map.resources :messages, :new =&gt; { :preview =&gt; :post }\n  # --&gt; POST /messages/new/preview (maps to the #preview action)\n  #     also adds a named route called &quot;preview_new_message&quot;\n\n  map.resources :messages, :new =&gt; { :new =&gt; :any, :preview =&gt; :post }\n  # --&gt; POST /messages/new/preview (maps to the #preview action)\n  #     also adds a named route called &quot;preview_new_message&quot;\n  # --&gt; /messages/new can be invoked via any request method\n\n  map.resources :messages, :controller =&gt; &quot;categories&quot;,\n        :path_prefix =&gt; &quot;/category/:category_id&quot;,\n        :name_prefix =&gt; &quot;category_&quot;\n  # --&gt; GET /categories/7/messages/1\n  #     has named route &quot;category_message&quot;\n"
- !ruby/struct:SM::Flow::P 
  body: "The #resources method sets HTTP method restrictions on the routes it generates. For example, making an HTTP POST on <tt>new_message_url</tt> will raise a RoutingError exception. The default route in <tt>config/routes.rb</tt> overrides this and allows invalid HTTP methods for resource routes."
full_name: ActionController::Resources#resources
is_singleton: false
name: resources
params: (*entities, &block)
visibility: public
