class AddDeviseToUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name, null: false
t.text :profile
end
end
t.string :email, null: false, default: ''
t.string :encrypted_password, null: false, default: ''
end
The definition of method t can only be used up to end for do in that create_table
class AddDeviseToUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name, null: false
t.text :profile
#I put the bottom two lines in do
t.string :email, null: false, default: ''
t.string :encrypted_password, null: false, default: ''
end
end
end
If rake db: migrate
is not reflected in Schema.rb
, please use rake db: migrate: rollback
to drop the migration and then rake db: migrate
.
[Reference materials] https://qiita.com/s_tatsuki/items/3e1f119c91e21b8f0c33
Recommended Posts