-1

I have a small problem that i am facing. When i started the project i used scaffold and defined due_date field as Date now i want to do some date calculations. and i need to change the due_date field to Datetime . Can sm1 help me with this I know how to add new fields to table and delete but i am stuck at changing the attribute of already existing Model.

I have tried everything. Please let me know if there is any special code i can run in terminal to edit the attribute and create migration file.

P.s- Someone told me changing the schema file is bad. so i cant edit it directly.

1 Answers1

0

first generate the migration

 rails g migration change_date_format_in_my_table

then inside your migration file add

  def up
    change_column :my_table, :my_column, :datetime
  end

  def down
    change_column :my_table, :my_column, :date
  end

run your migration and its done. :)

Ccr
  • 686
  • 7
  • 25