我想写一些类似的东西:
@meeting_requests = Meeting.where('meeting_time >= ? AND requestee_id IS ?
AND status = ?', Date.today, nil, "Active")
.joins(:requestor)
.where('birthyear >= ? AND birthyear <= ?',
current_user.birthyear - 10,
current_user.birthyear + 10 )
这有效:
@meeting_requests = Meeting.where('meeting_time >= ? AND requestee_id IS ?
AND status = ?', Date.today, nil, "Active")
这有效:
@meeting_requests = Meeting.joins(:requestor)
.where('birthyear >= ? AND birthyear <= ?',
current_user.birthyear - 10,
current_user.birthyear + 10 )
这样的事情有效:
Meeting.joins(:requestor).where('birthyear > ?', 1900).where(status: "Active")
但是我需要在meeting_time上做一个更大的查询,所以我需要把它写成一个我认为的字符串?
但是两个sql查询一起产生错误:ambiguous column name: status: SELECT
我觉得我很近......我在这里错过了什么?
答案 0 :(得分:3)
当不清楚列来自哪个表时,会显示此消息。这应该有效:
...rest_of_statement.where('meetings.status' => 'Active')