Ruby on rails has the t.timestamps method which creates two columns, created_at and updated_at. How can I make just the created_at column?
This works
class CreateLinesSources < ActiveRecord::Migration
def change
create_table :lines_sources do |t|
t.timestamps null: false
end
end
end
Both of these I want to work but fail
class CreateLinesSources < ActiveRecord::Migration
def change
create_table :lines_sources do |t|
t.created_at null: false
end
end
end
and
class CreateLinesSources < ActiveRecord::Migration
def change
create_table :lines_sources do |t|
t.timestamps null: false
remove_column updated_at
end
end
end
t.datetime :created_at, null: false
Just like any other column. Rails will still take care of magic updating because of column name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With