Rails 7, Enums, Models and Forms

I recently put together a “how-to use enums” in a Rails 7 project. Feel free to comment either on this thread or on the post itself. Here is the link: ActiveRecord, Enum and ActiveView Form | by Stéphane Paquet | Feb, 2022 | Medium Cheers

Thx for writing this up.

Though I wonder why anyone is actually using these weird ActiveRecord Enums.

I recommend everyone to use proper PostgreSQL Enums. This gem makes them easy to manage inside AR’s migrations and schema: activerecord-postgres_enum

Their largest advantage to me is that I have proper strings shown in database columns, which I can use when writing SQL statements - and don’t have to wonder if I need number 2 or 3.

1 Like