I am doing an online course , and I am trying to design a website with a user database . I have built a ” Contact Us” page with a form/table . I cannot make the timestamps show in the rails console $ Contact.all
this is my Schema.rb :
x
ActiveRecord::Schema.define(version: 20190518115940) do
create_table "contacts", force: :cascade do |t|
t.string "name"
t.string "email"
t.text "comments"
end
end
And this is the crate_contacts.rb file :
class CreateContacts < ActiveRecord::Migration[5.0]
def change
create_table :contacts do |t|
t.string :name
t.string :email
t.text :comments
t.timestamps
end
end
end
Advertisement
Answer
Your schema.rb
knows nothing about timestamps. Did you created the table without timestamps
and then you added it to the migration?
If so, you can rerun the migration (assuming it is the last one) with the command rails db:migrate:redo
, but all the data in that table will be wiped.
Refer to this guide for further options.