Reputation: 327
In a model I have some states
STATES = ["in_progress", "active", "archived"]
In my form I want a drop down/select with
In Progress, Active, Archived for english
and
ชำระ , ขัน , ยื่น in Thai
What is the best way to handle this ?
One option I have thought of is the following
def self.states
@states = {}
STATES.each do |s|
@states[s] = I18n.t(s)
end
@states
end
Is there a better way?
Upvotes: 0
Views: 76
Reputation: 6025
This is supported by simple_form:
In your view, you should just use
<%= f.input :state, collection: ["in_progress", "active", "archived"] %>
In your yaml file, you should have
simple_form:
options:
defaults:
state:
in_progress: In progress
active: Active
archived: Archived
Upvotes: 2