-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controller action ordering #289
Comments
I'd love to see a confirmation that this order is followed by real-world Rails apps. |
Just for the sake of discussion, another possible way of ordering could be to follow CRUD, e.g.:
|
Also, as this Stack Overflow post says, some people may prefer to group the |
I honestly like the CRUD order better, but consistency is my no. 1 priority. (I really just want to see a rubocop, but they refered me to this guide). |
I agree with the default order if this rule is needed. I think it's better to follow the scaffold order. This is the official starting point of Rails. |
What do you think of a soft wording for the guideline? e.g.
|
I don't think the default order is logical - How about "Use a consistent order of resourceful actions in your controller" |
This feels like it encourages non-resourceful actions, rather than just permitting them. How about:
|
Yes, and the order is grouped by HTTP method. However, the order displayed at http://localhost:3000/rails/info/routes is different: |
Since it's proving difficult to reach an agreed ordering, perhaps the guideline should just be to use a consistent ordering. A cop can then be written to allow the developer to configure their preferred order (without any default). |
The cop has been already written. I believe the issue remains open due to this comment. |
The default order of controller actions in rails scaffolds are:
index show new edit create update destroy
I often see controllers where this order is not followed. For consistency's sake, I'd like to have a rubocop to enforce this ordering of the public methods in my controllers.
As a side note: We strive towards never using any other actions in our controllers (https://www.youtube.com/watch?v=HctYHe-YjnE)
The text was updated successfully, but these errors were encountered: