【发布时间】:2010-05-13 18:04:36
【问题描述】:
我的 sqLite 数据库中有游戏,属性为starting_date(t.date:starting_date)。 我想知道所有已经开始的游戏,所以我使用这行代码:
Game.find :all,:conditions=>"starting_date <= #{Date.today}"
Game.find_by_sql("SELECT * FROM "games" WHERE (created_at < 2010-05-13)")
结果是 nill,即使我知道我已经有类似这样的游戏开始了:
#<Game id: 1, team_1_id: 2, team_2_id: 1, status: 2, team_1_points: nil, team_2_points: nil, starting_date: "2010-05-05", winner: 1, sport: "football", country: nil, league: "calcio", created_at: "2010-04-07 00:09:21", updated_at: "2010-05-13 00:57:19">
我在这里做错了什么?
【问题讨论】:
标签: sql ruby-on-rails activerecord