https://github.com/tanakaworld/enum_select_rails
A form helper for the enum field of Rails model.
https://github.com/tanakaworld/enum_select_rails
Last synced: 2 months ago
JSON representation
A form helper for the enum field of Rails model.
- Host: GitHub
- URL: https://github.com/tanakaworld/enum_select_rails
- Owner: tanakaworld
- License: mit
- Created: 2018-03-28T03:02:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T02:58:19.000Z (over 2 years ago)
- Last Synced: 2025-03-17T13:08:57.172Z (3 months ago)
- Language: Ruby
- Homepage: https://rubygems.org/gems/enum_select_rails
- Size: 59.6 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# EnumSelectRails
[](https://badge.fury.io/rb/enum_select_rails)
A form helper for the enum field of Rails model.
You can easily generate select tag which has enum field options.

## Installation
Add this line to your application's Gemfile:```ruby
gem 'enum_select_rails'
```## Usage
```ruby
class User
enum gender: {
female: 2,
male: 1,
other: 9
}
end
``````erbruby
<%= f.enum_select :gender %>
```## i18n
Automatically apply i18n text into options text.
This feature is depends on [enum_help](https://github.com/zmbacker/enum_help).

```ruby
# Gemfile
gem 'enum_help'
``````ruby
# application.rb
# i18n
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
``````yaml
# 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](http://opensource.org/licenses/MIT).