17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/enum_help/simple_form.rb', line 17
def initialize(*args)
super
raise "Attribute '#{attribute_name}' has no enum class" unless enum = object.class.send(attribute_name.to_s.pluralize)
collect = enum.collect{|k,v| [::I18n.t("enums.#{object.class.to_s.downcase}.#{attribute_name}.#{k}", default: k),k] }
collect.unshift [args.last[:prompt],''] if args.last.is_a?(Hash) && args.last[:prompt]
if respond_to?(:input_options)
input_options[:collection] = collect
else
@builder.options[:collection] = collect
end
end
|