In Ruby on Rails, what does “resource” mean?

I see the word resource in many different places, for example: Routing resource, resourceful controller and resources: photos. What does resource mean?

One more question: what does the RESTful route mean?

+7
source share
1 answer

This is a big question!

I would start here to better understand what a “resource” or “resources” does in terms of routing: http://guides.rubyonrails.org/routing.html#resource-routing-the-rails-default

The fact is that it formalizes a set of actions (for a specific controller) called by pairs of URL / HTTP verbs that are responsible for changing the state of a given resource. Think of resources as nouns: Order, LineItem, Offer and think about what you can do with these nouns: as a rule, create them, delete, modify, extract some of them, etc. Thus, resources often (but certainly not necessarily) are your main model objects and / or some composite representation of these basic models.

Again, the Rails guides summarize which resourceful Rails routes are very briefly described in section 2.1 of the above link: "In Rails, a resourceful route provides a mapping between HTTP verbs and URLs and controller actions"

If you are not familiar with REST, Wikipedia has a decent, but not exhaustive architecture coverage: http://en.wikipedia.org/wiki/Representational_State_Transfer .

+10
source

All Articles