Class | Rails::Generator::GeneratedAttribute |
In: |
vendor/rails/railties/lib/rails_generator/generated_attribute.rb
|
Parent: | Object |
column | [RW] | |
name | [RW] | |
type | [RW] |
# File vendor/rails/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
# File vendor/rails/railties/lib/rails_generator/generated_attribute.rb, line 26 26: def default 27: @default ||= case type 28: when :integer then 1 29: when :float then 1.5 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 36: else 37: "" 38: end 39: end
# File vendor/rails/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 :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 21: else 22: :text_field 23: end 24: end