Module: ActiveEnum::FormHelpers::SimpleForm::InputExtension

Included in:
EnumInput
Defined in:
lib/active_enum/form_helpers/simple_form.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/active_enum/form_helpers/simple_form.rb', line 19

def initialize(*args)
  super
  raise "Attribute '#{attribute_name}' has no enum class" unless enum = object.class.active_enum_for(attribute_name)
  if respond_to?(:input_options)
    input_options[:collection] = enum.to_select
  else
    @builder.options[:collection] = enum.to_select
  end
end