Router actions

Hi,

Are :index, :new, :create, :show, :update, :create, :delete actions keywords in the router?

For instance, is a route to '/' and :index action in controller always a GET rest operation?

And does there always have to be an :index action? I would like to create a GET ‘/’ operation, but with my own custom function name, not named index. Is that possible?

The resources macro is meant to create a common rest setup for a controller, but you can always create other routes using get, post, … macros.

Thanks, I should have asked, are the 7 actions reserved keywords? E.g. with a User model, is :index always with GET and /users , and :show is with GET and /users/:id, etc.?

No, using the resource macro just sets up a bunch of conventional routes, if you specify them one by one, you can use whatever scheme and names you want for your actions.

1 Like