Class: Rails::Generator::GeneratedAttribute

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

Instance Method Summary collapse

Instance Method Details

#default_valueObject



288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/awesome_scaffold_generator.rb', line 288

def default_value
  @default_value ||= case type
    when :int, :integer               then "\"1\""
    when :float                       then "\"1.5\""
    when :decimal                     then "\"9.99\""
    when :datetime, :timestamp, :time then "Time.now"
    when :date                        then "Date.today"
    when :string                      then "\"MyString\""
    when :text                        then "\"MyText\""
    when :boolean                     then "false"
    else
      ""
  end      
end

#input_typeObject



303
304
305
306
307
308
309
# File 'lib/awesome_scaffold_generator.rb', line 303

def input_type
  @input_type ||= case type
    when :text                        then "textarea"
    else
      "input"
  end      
end