Delete attribute from model in Ruby on Rails
Create a new migration with
rails g migration migrationname
and in the migration's up method run the following
remove_column :users, :age
run rake db:migrate and you are good to go.
At least two choices:
- You can run
rake db:rollback
, delete the field from the migration and then re-runrake db:migrate
- You can create a new migration to delete the field with
rails generate migration new_migration
.