Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 480 Bytes

README.md

File metadata and controls

25 lines (20 loc) · 480 Bytes

StringifiedEnum

How to use?

in your Gemfile

gem "stringified_enum"

in you ActiveRecord model

class Item < ApplicationRecord
  include StringifiedEnum

  stringified_enum status: %i(active inactive)
end

How does it work?

It works as a shortcut for the original ActiveRecord::Enum definition. For example the code above is equivalent to:

class Item < ApplicationRecord
  enum status: { active: "active", inactive: "inactive" }
end