5
class GeneratedAttribute
6
attr_accessor :name, :type, :column
8
def initialize(name, type)
9
@name, @type = name, type.to_sym
10
@column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type)
14
@field_type ||= case type
15
when :integer, :float, :decimal then :text_field
16
when :datetime, :timestamp, :time then :datetime_select
17
when :date then :date_select
18
when :string then :text_field
19
when :text then :text_area
20
when :boolean then :check_box
27
@default ||= case type
30
when :decimal then "9.99"
31
when :datetime, :timestamp, :time then Time.now.to_s(:db)
32
when :date then Date.today.to_s(:db)
33
when :string then "MyString"
34
when :text then "MyText"
35
when :boolean then false
42
[ :references, :belongs_to ].include?(self.type)