正在開發Ruby on Rails教程。我剛剛注意到,當我生成我的遷移時,我拼錯了一個列名。當我嘗試使用關聯時,出現此錯誤。Ruby on Rails,活動記錄更新
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
>>
我的問題是如何更新有效位置的正確拼寫的活動記錄。我在我的Schema文件中更改了它。
感謝RubySolo。 –
我當然不會推薦它在你的生產服務器上,而是在你的開發工作站上(特別是在通過教程時),這很好。 – rubysolo
沒有。它會刪除數據庫,然後重新運行所有遷移,因此根據定義,它使數據庫與所有遷移的結果相匹配。 – rubysolo