Forum: Ruby on Rails Restful routing, restful versus non-restful routes

236dd7ca555806d7c971f1af1523a3d5?d=identicon&s=25 Srdjan Cengic (Guest)
on 2013-11-18 10:37
(Received via mailing list)
So resources :products will create 7 different restful routes for CRUD
operations for resource products.
For example: products GET /products(.:format) products#index

So restful route includes only controller name within itself and :id for
operation like edit, show, update, delete.
When i create *non-restful* routes in rails for example: get
':controller/:action/:id' i only can see difference that i
*must*explicitly write
:action, so that ":action" makes this route non-restful?

*So as i get this, first requirement for route(URL) to be restful is
route can't contain action name?* *Question 1*

Second requirement for route to be restful is that action corresponding
route must "play by restful rules" in another word,
for example a GET should not leave side-effects on the server, but just
retrieve data.
So if i have /products(.:format) products#index and within index action
saved something into DB, *than above route is just looks like restful
but in fact it isn't*? *Question 2*

I know that i can pass to restful route additional parameters, for
link_to "Show", products_path(id: 5, a: "aaaa", b: "bbbb") so now URL
So am i violating restful here, or this route is still restful?
*Question 3*

To me seems that i don't need *non*-restful routes at all, when i can
a bunch of restful routes with construct like following?(and other
*Question 4*

resources :products do
  member do
    get 'preview'

And just one more question, is there anything bad(maybe code smell or
something) to make restful routes when i don't have model in database.
So for example, resources :sessions, where i don't have session model(no
sessions table in DB).
*Question 5*
Please don't redirect me to i
read it multiple times :)
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.