module WonderfulSimpleForms::SimpleForm::BuilderExtension

Public Instance Methods

default_input_type_with_belongs_to(*args, &block) click to toggle source
# File lib/wonderful_simple_forms/simple_form.rb, line 14
def default_input_type_with_belongs_to(*args, &block)
  att_name = (args.first || "#{@attribute_name}").to_s
  options = args.last
  return :belongs_to if (
    object.class.reflect_on_all_associations(:belongs_to).any? { |a| a.name == args.first })

  default_input_type_without_belongs_to(*args, &block)
end
default_input_type_with_enum(*args, &block) click to toggle source
# File lib/wonderful_simple_forms/simple_form.rb, line 5
def default_input_type_with_enum(*args, &block)
  att_name = (args.first || @attribute_name).to_s
  options = args.last
  return :enum if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? &&
                  is_enum_attributes?( att_name )

  default_input_type_without_enum(*args, &block)
end
is_enum_attributes?( attribute_name ) click to toggle source
# File lib/wonderful_simple_forms/simple_form.rb, line 23
def is_enum_attributes?( attribute_name )
  object.class.respond_to?(:defined_enums) &&
    object.class.defined_enums.key?(attribute_name) &&
    attribute_name.pluralize != "references"
end