今天把blog的body字段通过migration改名为content,然后rake db:migrate,再rake db:migrate RAILS_ENV=test。结果再次运行unit test的时候,居然报这样的错:[quote]ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'body' in 'field list'[/quote]
想了半天想不起来除了数据库里还有哪里定义了model的信息。结果跑到rubyonrails的guides上乱翻,看到这么一行:
[quote]$ script/generate scaffold post title:string body:text
...
create app/models/post.rb
create test/unit/post_test.rb
create test/fixtures/posts.yml
...[/quote]
这才反应过来……估计fixtures里的信息不会同步更新。打开blog.yml一看,果然如此,于是把里面的body全改成content,再次运行测试,正常了。。
想了半天想不起来除了数据库里还有哪里定义了model的信息。结果跑到rubyonrails的guides上乱翻,看到这么一行:
[quote]$ script/generate scaffold post title:string body:text
...
create app/models/post.rb
create test/unit/post_test.rb
create test/fixtures/posts.yml
...[/quote]
这才反应过来……估计fixtures里的信息不会同步更新。打开blog.yml一看,果然如此,于是把里面的body全改成content,再次运行测试,正常了。。