mysql,Linux,HighPerformance,ruby on Rails





RubyHunt: What’s the use of the :collection and :member methods within a route? What’s the difference between the two?
melvinram: Collection adds routes to the entire collection
RubyHunt: So the collection is used to add another action inside the controller
melvinram: If you had a resource of Contacts, a collection route you might add would be delete_all_older_than_6_months
melvinram: and the route to get to it would be be /contacts/delete_all_older_than_6_months/
RubyHunt: Which otherwise would be restricted to only 7 actions ?
melvinram: yes
melvinram: A member method applies only to one record. For example, you might add a member method called upgrade_to_vip that would update one record to have a status of VIP or something…
melvinram: And the route would be /contacts/1/upgrade_to_vip
RubyHunt: So the :collection is used to add action inside a RESTful controller and the :member would be used to apply action for individual object.