I had a model called Person after following a tutorial online. After a while we decided that it was more sensible to rename it to User. I went through the code base and did the following:
- Renamed all instances of Person to User, person to user, People to Users and people to users, taking care not to clobber anything unrelated.
- Renamed all model files appropriately.
I have another model called session:
session belongs_to user
and
user has_many sessions
Prior to running migrations git grep -i person / people and find | grep person / people just return migrations so I’m sure that I have renamed everything properly.
When I go to create a new user which subsequently creates a session I get the following error:
unknown attribute: user_id
Running git grep again I find that the foreign key in sessions is still person_id
create_table "sessions", :force => true do |t|
t.integer "person_id
t.string "ip_address"
t.string "path"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
How can I fix this?
just do in a migration