0
여행에 속한 주제 모델이 있습니다. 여행에는 start_date 및 end_date가 있습니다. 여행 날짜를 기준으로 주제를 찾고 싶습니다. 레일즈에서이 쿼리를 어떻게 설정합니까?관계를 기반으로 한 모델 검색
Topic.joins(:trip).where('trip.start_date > ?', Time.now)
다음과 같은 오류가 발생합니다.
Topic Load (0.3ms) SELECT "topics".* FROM "topics" INNER JOIN "trips" ON "trips"."id" =
"topics"."trip_id" WHERE (trip.start_date < '2014-10-22 13:17:37.764743') ORDER BY created_at DESC
SQLite3::SQLException: no such column: trip.start_date: SELECT "topics".* FROM "topics" INNER JOIN
"trips" ON "trips"."id" = "topics"."trip_id" WHERE (trip.start_date < '2014-10-22 13:17:37.764743')
ORDER BY created_at DESC
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: trip.start_date: SELECT
"topics".* FROM "topics" INNER JOIN "trips" ON "trips"."id" = "topics"."trip_id" WHERE
(trip.start_date < '2014-10-22 13:17:37.764743') ORDER BY created_at DESC
어떻게이 쿼리를 잘못 구성합니까?
내 대답이 도움이 되었습니까? –
예, 감사했습니다! –