0
class Campaign < ActiveRecord::Base
has_many :posts
has_many :users
end
class Post < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :campaign
end
class User < ActiveRecord::Base
has_and_belongs_to_many :posts, :join_table => "users_posts"
belongs_to :campaign
end
사용자가이 게시물을 보았을 때 나는 그를 post.users에 추가합니다. 내가 처음으로 사용자 캠페인의 미가공 게시물을 찾아야합니다. Smth like this :연관성없이 연관성없이 모두 찾으십시오.
current_user.campaign.posts.where('posts.users not include current_user')