Methods
Attributes
[RW] | column | |
[RW] | name | |
[RW] | type |
Public Class methods
[ show source ]
# File railties/lib/rails_generator/generated_attribute.rb, line 8 8: def initialize(name, type) 9: @name, @type = name, type.to_sym 10: @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type) 11: end
Public Instance methods
[ show source ]
# File railties/lib/rails_generator/generated_attribute.rb, line 27 27: def default 28: @default ||= case type 29: when :integer then 1 30: when :float then 1.5 31: when :decimal then "9.99" 32: when :datetime, :timestamp, :time then Time.now.to_s(:db) 33: when :date then Date.today.to_s(:db) 34: when :string then "MyString" 35: when :text then "MyText" 36: when :boolean then false 37: else 38: "" 39: end 40: end
[ show source ]
# File railties/lib/rails_generator/generated_attribute.rb, line 13 13: def field_type 14: @field_type ||= case type 15: when :integer, :float, :decimal then :text_field 16: when :time then :time_select 17: when :datetime, :timestamp then :datetime_select 18: when :date then :date_select 19: when :string then :text_field 20: when :text then :text_area 21: when :boolean then :check_box 22: else 23: :text_field 24: end 25: end
[ show source ]
# File railties/lib/rails_generator/generated_attribute.rb, line 42 42: def reference? 43: [ :references, :belongs_to ].include?(self.type) 44: end