Skip to content
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

Add "Positional arguments" subsection #356

Closed

Conversation

maxprokopiev
Copy link

@@ -422,6 +422,8 @@ end

=== Enums [[enums]]

=== Hash syntax [[hash-syntax]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a sub-section, so four ====

@@ -440,6 +442,22 @@ class Transaction < ApplicationRecord
end
----

=== Positional arguments [[positional-arguments]]

Prefer using positional arguments instead of keyword arguments when defining enums.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m on the fence if this should be in the guide.
I can see the Rails team trying to get rid of the code that detects the enum attribute name.

I can also see potential mistakes like enum status: {a: 1}, priority: {high:1,…}. But is it common?

But how does that stylistically differ for the rest of us? Why do people need to care? If it’s older Rails - use any of the teo. If it’s new, only the positional would work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - since deprecation notice captures the old syntax, seems like we don't need to have a dedicated cop for this at all, I'll close both PRs 😬

thanks for the feedback!

@pirj pirj closed this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants