Skip to content
A form helper for the enum field of Rails model.
Ruby HTML CSS JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
test
.gitignore
Gemfile
Gemfile.lock
MIT-LICENSE
README.md
Rakefile
_config.yml
enum_select_rails.gemspec

README.md

EnumSelectRails

Gem Version

A form helper for the enum field of Rails model.

You can easily generate select tag which has enum field options.

image

Installation

Add this line to your application's Gemfile:

gem 'enum_select_rails'

Usage

class User
  enum gender: {    
    female: 2,
    male: 1,
    other: 9
  }
end
<%= f.enum_select :gender %>

i18n

Automatically apply i18n text into options text.

This feature is depends on enum_help.

image

# Gemfile
gem 'enum_help'
# application.rb
# i18n
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
# config/locales/models/user/ja.yml
ja:
  activerecord:
    models:
      user: ユーザー
    attributes:
      user:
        gender: 性別
  enums:
    user:
      gender:
        female: 女性
        male: 男性
        other: その他

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.