rails has_many :through – Is it possible to have a conditions in the through table?

Jochen’s link has a good solution – but :conditions is deprecated and the :conditions => ['event_users.active = ?',true] bit just doesn’t seem very rails. Try this:

has_many :game_users
has_many :game_likes, -> { where like: true }, class_name: 'GameUser'
has_many :liked_games, :through => :game_likes, class_name: 'Game', :source => :game

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)