How to Properly Configure Rails 4.1 Enums in ActiveAdmin

Building off of Jack’s answer, here’s what worked for me. Say your ActiveRecord model is Tweets:

f.input :privacy_level, as: :select, collection: Tweet.privacy_levels.keys

Key things to note here:

  • your ActiveRecord has a useful dictionary (available at enum_name.pluralize) of enum keys to values.
  • using strings (and ignoring the underlying integer representation) makes it easier to write to the enum value.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)