【发布时间】:2013-03-01 10:55:03
【问题描述】:
我有这个方法,在 rake 任务之后应该将我的数据保存到模型中,我试图一次更新 2 列,这应该不是问题
def update_fixtures #rake task method
Fixture.destroy_all
get_home_fixtures.each {|home| Fixture.create!(home_team: home )}
get_away_fixtures.each {|away| Fixture.create!(away_team: away )}
end
在这种情况下,只有客队会拯救,但是如果我这样做
def update_fixtures #rake task method
Fixture.destroy_all
get_away_fixtures.each {|away| Fixture.create!(away_team: away )}
get_home_fixtures.each {|home| Fixture.create!(home_team: home )}
end
那么只有主队会扑救。
我尝试了@model.errors.full_messages,但得到了 nil 类的未定义方法,所以没有?
我正在尝试调试此问题,但不确定我可以使用什么来查找问题
以前有人经历过吗?把我逼疯了
编辑
我可以从控制台手动更新该字段,所以当我这样做时
Fixture.create(:away_team => "String")
更新正常
谢谢
【问题讨论】:
标签: ruby-on-rails-3 debugging activerecord methods rake-task