Git Product home page Git Product logo

Comments (11)

andyw8 avatar andyw8 commented on June 19, 2024 4

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.

pirj avatar pirj commented on June 19, 2024 2

I'd love to see a confirmation that this order is followed by real-world Rails apps.

from rails-style-guide.

mollerhoj avatar mollerhoj commented on June 19, 2024 2

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.

ydakuka avatar ydakuka commented on June 19, 2024 1

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.

andyw8 avatar andyw8 commented on June 19, 2024

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.

andyw8 avatar andyw8 commented on June 19, 2024

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.

mollerhoj avatar mollerhoj commented on June 19, 2024

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.

koic avatar koic commented on June 19, 2024

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.

pirj avatar pirj commented on June 19, 2024

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.

ydakuka avatar ydakuka commented on June 19, 2024

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.

andyw8 avatar andyw8 commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.