Class: CafeCar::Filter::FieldInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/cafe_car/filter/field_info.rb

Instance Method Summary collapse

Instance Method Details

#i18n(key, **opts) ⇒ Object



2
3
4
5
# File 'lib/cafe_car/filter/field_info.rb', line 2

def i18n(key, **opts)
  I18n.t(@method, scope: [ :helpers, :filter, key, i18n_key ], raise: true, **opts)
rescue I18n::MissingTranslationData
end

#inputObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cafe_car/filter/field_info.rb', line 7

def input
  case type
  when :string   then :text_field
  when :text     then :text_field
  when :decimal  then :text_field # :range_field
  when :integer  then :text_field # :range_field
  when :date     then :text_field
  when :datetime then :text_field
  when :password then :password_field
  when :belongs_to, :has_many then :association
  when :has_one
    rich_text? ? :text_field : nil
  else raise "Missing input type for #{model_name}##{@method} of type :#{type}"
  end
end