Ruby on Rails RESTful controller function order -


i'm pretty new rails , have been going through process of building rest service. in rails guide seems pretty specific when tell in controller class add functions: create after new, show before new, etc. guess curious if there convention people use ordering (when rake routes order is: index, create, new, edit, show, update, destroy). not big deal long project consistent, there "conventional order" people use? if not, guess argue who's order better.

thanks!

the order of controller actions isn't important @ all, follow same convention rails uses in it's own scaffolded controllers.

this way, can scan controller action i'm looking when open controller file.

index, show, new, edit, create, update, destroy

i think order makes sense, index , show both concerned "showing" or "reading" data, primary concern in web app.

then new , edit, , create concerned "creating", should grouped together.

after create update, similar.

then there's destroy, simple , action of it's kind.

when adding custom actions controller, keep them near action like, in terms of interactions.

if have method display subset or collection of things, i'll put under index. if have actions upvote or downvote things, think fit nicely under update, since updating part of record.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -