class GameSystem < ActiveRecord::Base
has_many :cartridges
end
class Cartridge < ActiveRecord::Base
belongs_to :game_system
end
I want to be able to do:
GameSystem.joins(:cartridges)
.where({:cartridge => { :name => 'Dragons Lair', :publisher => 'Cinematronics' })
.where({:cartridge => { :name => 'Zaxxon', :publisher => 'Sega' })
.limit(1)
In other words, tell me if there exists a game system where there was a Dragon's Lair cartridge by Cinematronics, AND a cartridge named Zaxxon by Sega...
Is there an activerecord friendly way to do this?