Skip to content

Commit

Permalink
Add section for hash syntax of enums
Browse files Browse the repository at this point in the history
  • Loading branch information
tejasbubane committed Jul 8, 2019
1 parent c0edf66 commit 3d33dc2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.adoc
Expand Up @@ -385,6 +385,24 @@ class Transaction < ActiveRecord::Base
end
----

=== Enums [[enums]]

Prefer hash syntax over arrays for `enums`.

[source,ruby]
----
class Transaction < ActiveRecord::Base
# bad - implicit values - ordering in array matters
enum type: %i[credit debit]
# good - explicit values - ordering does not matter
enum type: {
credit: 0,
debit: 1,
}
end
----

=== Macro Style Methods [[macro-style-methods]]

Group macro-style methods (`has_many`, `validates`, etc) in the beginning of the class definition.
Expand Down

0 comments on commit 3d33dc2

Please sign in to comment.