working on a tutorial for Ruby on Rails. I just noticed that I had miss-spelled one of my column names when I generated my migrations. When I try to work with associations I get this error.
first_page = Page.new(:name => "first page", :permalink => 'first', :position => 1)
ActiveRecord::UnknownAttributeError: unknown attribute: position
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.8/lib/active_record/base.rb:1564:in `attributes='
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.8/lib/active_record/base.rb:1560:in `each'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.8/lib/active_record/base.rb:1560:in `attributes='
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.8/lib/active_record/base.rb:1412:in `initialize'
from (irb):5:in `new'
from (irb):5
>>
My question is how do I update active record with the correct spelling of the Position. I've changed it in my Schema file.
fix your initial migration to have the correct spelling, then run:
$ rake db:migrate:reset
This will delete your development database (and any data in it!), create an empty development db, and re-run all the defined migrations against it.