Search code examples
ruby-on-rails-4enums

Rails: How to use i18n with Rails 4 enums


Rails 4 Active Record Enums are great, but what is the right pattern for translating with i18n?


Solution

  • I didn't find any specific pattern either, so I simply added:

    en:
      user_status:
        active:   Active
        pending:  Pending...
        archived: Archived
    

    to an arbitrary .yml file. Then in my views:

    I18n.t :"user_status.#{user.status}"