私は3つの単純なモデルを持っています:
class User < ActiveRecord::Base
has_many :subscriptions
end
class Game < ActiveRecord::Base
has_many :subscriptions
end
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :game
end
私が疑問に思っているのは、特定のユーザーがゲームにサブスクライブしているかどうかを含む「is_subbed」という別の属性をゲームにクエリするときに含めることは可能ですか? 何かのようなもの:
a_user = User.first
games = Game.scoped
games.conditions blah blah blah
ゲームには、is_subed と呼ばれる a_user にカスタムされる「仮想」属性またはメモリ内属性が含まれます。