Comments (11)
Feel free to intermingle them with additional non-resourceful actions deliberately.
This feels like it encourages non-resourceful actions, rather than just permitting them. How about:
Use a consistent order for the resourceful actions in your controller. Non-resourceful actions can be interspersed where needed.
from rails-style-guide.
I'd love to see a confirmation that this order is followed by real-world Rails apps.
from rails-style-guide.
I don't think the default order is logical - How about "Use a consistent order of resourceful actions in your controller"
from rails-style-guide.
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.
from rails-style-guide.
Just for the sake of discussion, another possible way of ordering could be to follow CRUD, e.g.:
new create index show edit update destroy
from rails-style-guide.
Also, as this Stack Overflow post says, some people may prefer to group the new/create
and edit/update
pairs together.
from rails-style-guide.
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).
from rails-style-guide.
The default order of controller actions in rails scaffolds are:
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.
from rails-style-guide.
What do you think of a soft wording for the guideline? e.g.
Use the default order of resourceful actions in your controller. Feel free to intermingle them with additional non-resourceful actions deliberately.
from rails-style-guide.
The default order of controller actions in rails scaffolds are:
index show new edit create update destroy
Yes, and the order is grouped by HTTP method.
However, the order displayed at http://localhost:3000/rails/info/routes is different:
index create new edit show update destroy
from rails-style-guide.
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).
from rails-style-guide.
Related Issues (20)
- Per attribute validations
- Prefer `ActionDispatch::IntegrationTest` over `ActionController::TestCase`
- Better docs for `dependent: :destroy` HOT 1
- Where with Ranges: "good" vs "bad" are not equivalent HOT 3
- Description of Single Attribute Validations seems wrong. HOT 1
- Suggestion: Avoid `render ... and return` HOT 4
- Suggestion: Use string literals instead of named routes or URL helpers in tests HOT 2
- Add delete_all to the list of methods that skip model validations HOT 2
- New cop: Every AR find must either be in a conditional or be a bang HOT 1
- Cop suggestion: PreferCreateJoinTable HOT 4
- Cop idea: prefer symbol proc to `if:` and `unless:` filter lambdas HOT 2
- Are blank routes preferred or routes with `/`
- Suggestion: Add notes about `.none()` HOT 1
- Suggestion: Add notes about returned value of ActiveRecord transaction
- Suggestion: Add description about Active Record redundant `all` HOT 1
- Suggestion: don't divide `.where.not` into two lines
- Suggestion: 3-state booleans don't require a default HOT 3
- "Redundant `all`" is too naive HOT 10
- Cop idea: merge `.first` || `.create!` into `.first_or_create!` HOT 6
- Cop idea: Prefer `assert_raises` over `assert_raise` HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails-style-guide.