Tech specs: ruby 2.1.5p273, Rails 4.2.3.
I need to pull a list of child records, based on it's own parameters and it's parent's parameters.
Child = Video
Parent = Player
The "date" attribute belongs to Video, the "org_id" belongs to Player.
I tried:
@videos = Video.where(date: start_date..end_date).includes(:player_page).
where(org_id: org_id)
but I get:
Mysql::Error: Unknown column 'videos.org_id' in 'where clause': SELECT `videos`...
basically, the second where clause is querying Videos, not Players.
To sum up: my intention is to query a set of Video records that fit within a date range and also match its parent's org_id. Thanks in advance for any help.
Try this:
@videos = Video.where(date: start_date..end_date).includes(:player_page).
where(player_page: { org_id: org_id })
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments