RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Handle static list in your database (enums-like functionnality)

So, sometimes, In your application you may want to handle things in your User model like sex (female, male) or other static lists. You don’t like ENUM. You want these lists to be handled using ‘textual keys’ in your application but stored in your database using codes in an integer column. You don’t want to join other tables to display these information. You want these lists to be easily ordered, localized and translated using Rails i18n.You want view helpers to display these lists localized and validations helpers to validate the values in the ‘receiving’ model. That’s why we wrote static_list. It’s just a gem install away !

Comments

Those interested in this may also find coded_options useful. Similar idea, different syntax.

Well, there is also https://bitbucket.org/starware/super_map/src which has at least that functionality and is more mature than 0.1.0

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in