I`m new to RoR. Please help me:
I have two models:
class User < ActiveRecord::Base
belongs_to :game
end
and
class Game < ActiveRecord::Base
has_many :users, :foreign_key => "game_id"
end
Game objects have many users. I need to find all Game objects, where users.count == 1. Please help.
A bit long but this worked for me:
You can use
includes()orjoins()depending on what you want to do.