Class: MegaScaffold::TypeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/mega_scaffold/type_detector.rb

Class Method Summary collapse

Class Method Details

.find_type(field) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mega_scaffold/type_detector.rb', line 3

def TypeDetector.find_type(field)
  case field.type
  when :datetime
    :datetime_field
  when :date
    :date_field
  when :text
    :text_area
  when :boolean
    :check_box
  when :integer
    :number_field
  else
    case field.name
    when /password/
      :password_field
    when /phone/
      :phone_field
    when /email/
      :email_field
    when /color/
      :color_field
    when /url/
      :url_field
    else
      :text_field
    end
  end
end