Retrieving all posts from boards that a user’s subscribed to

Here I have a scenario where a user can subscribe to a message board and receive all posts created from that board. There’s only one stipulation, which is that posts created by the subscribed user from each board is filtered out. Here is what I came up with:

class User < ApplicationRecord   has_many :subscriptions, dependent: :destroy end  class Post < ApplicationRecord   belongs_to :board   belongs_to :user end  class Subscription < ApplicationRecord   belongs_to :user   belongs_to :board end 

class FeedController < ApplicationController   def index     @posts = Post.left_outer_joins(board: :subscriptions).where(board: { subscriptions: { user_id: } } ).where.not(user_id:   end end 

I’d like to get feedback particularly for the manner how I query for the current user’s subscription posts in my controller.

Post.left_outer_joins(board: :subscriptions).where(board: { subscriptions: { user_id: } } ).where.not(user_id: