Skip to content

Instantly share code, notes, and snippets.

@ShPakvel
Created June 25, 2014 10:11
Show Gist options
  • Save ShPakvel/3ccffcc6138f73b84804 to your computer and use it in GitHub Desktop.
Save ShPakvel/3ccffcc6138f73b84804 to your computer and use it in GitHub Desktop.
Rails 4 enum and simple_form with I18n
<%= simple_form_for(@event) do |f| %>
<div class="form-inputs">
<%= f.input :status, collection: Event::STATUSES %>
...
<% end %>
class Event < ActiveRecord::Base
STATUSES = [ :cancelled, :in_progress, :completed, :invoiced ]
enum status: STATUSES
...
end
@aalvrz
Copy link

aalvrz commented Aug 23, 2017

@faouzzz

Where is the i18n translation for the enums in that example?

@anton-osennikov
Copy link

anton-osennikov commented Nov 8, 2018

simple_form i18n translation for the enum in Event.rb example above is found at:

en:
  simple_form:
    options:
      event:
        status:
          cancelled: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment