Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:07:04+00:00 2026-05-20T11:07:04+00:00

Reading this: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions What does it mean to add a ‘member route’? or do

  • 0

Reading this: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions

What does it mean to add a ‘member route’?

or do add a route to the collection?

What is a member and a collection when talking about routes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:07:05+00:00Added an answer on May 20, 2026 at 11:07 am

    They’re both ways to add additional actions to a resource-based route in Rails.

    • A member route requires an ID, because it acts on a member.
    • A collection route doesn’t require an ID because it acts on a collection of objects.

    I like to think of them in terms of RESTful URLs. Consider the basics for a resource/model Foo

    GET    /foo            # FooController#index
    GET    /foo/:id        # FooController#show
    GET    /foo/new        # FooController#new
    POST   /foo            # FooController#create
    GET    /foo/:id/edit   # FooController#edit
    PUT    /foo/:id        # FooController#update
    DELETE /foo/:id        # FooController#destroy
    

    Notice how:

    • Some routes have :id placeholders for Foo.id, and so refer to a specific Foo
    • Some routes have no :id, and thus refer to all Foos (and/or no specific foo, as in #new and #create)
    • Some routes (index/create, show/update/destroy) have the same URL, and use HTTP methods to differentiate between them
    • Some routes (edit/show) are basically the same (method & URL prefix) except for a different suffix (including “no suffix”) at the end.

    Member routes and collection routes let you add additional routes/actions using the same techniques as I listed above.

    A member route adds a custom action to a specific instance using the URL suffix and HTTP method you provide. So, if you had a member route declaration of :member => { :bar => :get }. you’d get an additional route of:

    GET    /foo/:id/bar # FooController#bar
    

    Note how it overloads GET /foo/:id in the same way that `edit’ does. This is how you’d implement a “delete” action that provides a UI for the “destroy” action.

    Similarly, a collection route adds an overload to the collection and/or a non-specific instance (it’s up to you to decide exactly what it implies). So, if you declared :collection => { :baz => :get }, you’d get an additional route:

    GET    /foo/baz        # FooController#baz
    

    …in very much the same way as new.

    You can also customize the HTTP method.

    For example, I just recently had a project where I needed a “reply” action on a Comment. It’s basically the same idea as Comment#create (which uses POST), except that it’s in reference to a specific parent Comment. So, I created a member route: :member => { :reply => :post }. This gave me:

    POST   /comment/:id/reply   # CommentController#reply
    

    This keeps the routes restful while still expanding upon the basic 7 actions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to rails and I am reading http://guides.rubyonrails.org/getting_started.html . There is an
I want to improve performance of my app, and started reading http://guides.rubyonrails.org/performance_testing.html . My
I was reading this today: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#default-parameter-values and I can't seem to understand what's happening
I was reading this article on Coding Horror: http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I went to the downloads
I was reading this http://developer.android.com/guide/topics/wireless/bluetooth.html#QueryingPairedDevices which is allot of help on how to pair,connect
I'm trying to use behat and mink together, reading that link: http://docs.behat.org/cookbook/behat_and_mink.html#method-1-composer and trying
Reading through the Grails docs (see here http://grails.org/doc/latest/guide/theWebLayer.html#ajax ), I was led to believe
I'm reading this Application Server Specific Configuration Guide, http://axis.apache.org/axis2/java/core/docs/app_server.html , for Axis2. What does
I am reading this tutorial http://developer.android.com/guide/google/play/billing/billing_testing.html and it is really confusing me :) In
I was reading this two docs about Service in the Android SDK http://developer.android.com/reference/android/app/Service.html http://developer.android.com/guide/components/services.html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.