我想写一些类似的东西:
@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
ambiguous column name: status: SELECT
我觉得我好近……我在这里想念什么?
当不清楚该列来自哪个表时,会出现此消息。这应该工作:
...rest_of_statement.where('meetings.status' => 'Active')