REST stands for Representational State Transfer and is a fancy term that encompasses
the stateless design of the HTTP protocol and hence the World Wide Web as a whole.
A short list of REST principles follow:
Now back to rails. On one hand adherence to "RESTful" practices is used as a big stick to beat people over the head, while on the other hand rails embraces non-REST practices. Rails supports sessions, which are commonly implemented via cookies. Cookies are almost the defacto non-REST web practice used world-wide. The ivory tower condemns them, the real world uses them every day. And then we get to the business of using the verbs provided to us by HTTP. The verbs we would like to use are GET, POST, PUT, and DELETE. We are immediately confronted by a problem - only GET and POST are supported by real world browsers! That doggone real world getting in the way of the ivory tower again. So rails, hell bent on following REST "best practices" come what may, puts a hidden field "_method" onto POST requests and sets it to "put" or "delete" as necessary. A dirty little secret the high horse REST crowd would probably be reluctant to admit, if they are aware of it at all.
My suspicion is that the rails REST zealots are just fundamentalist islamics that don't yet realize that they were born in the wrong country. I am, on the other hand, entirely utilitarian about my programming tools. I am not trying to make them into a religion, and I place value on them only according to how well the perform as tools, not their moral purity.
map.resources :thingsAnd you have a model called "thing", you get seven handy routes set up for you as a package deal. Here are the controller actions and the routes set up to map to them:
To generate a link to a form that will crank out a new item, do this:
link_to "Create a new thing", new_thing_pathThis produces a URL to /things/new, which does GET by default.
To generate a link to a form that will edit an already fetched item, do this:
edit_thing_url(@thing)The tricky business to insert the _method settings is done for you in the form generation methods provided by rails.
This is what you really need to know about being "RESTful".
Ruby on Rails notes / [email protected]