我已经多次做过这种类型的陈述,但它现在告诉我这个陈述含糊不清。这是错误:
Mysql::Error: Column 'created_at' in where clause is ambiguous: SELECT COUNT(DISTINCT `tasks`.`id`) AS count_id FROM `tasks` LEFT OUTER JOIN `users` ON `users`.`id` = `tasks`.`author_id` WHERE (created_at >= '2012-01-14 18:38:29')
这是声明:
Task.count(:conditions => ["created_at > ?", 1.month.ago])
我在这里做错了什么?
答案 0 :(得分:5)
尝试:
Task.count(:conditions => ["tasks.created_at > ?", 1.month.ago])
您的每个表都可能有一个created_at,因此您必须指定要在查询中定位的表。