sql – Retrieve all the publications of the boards to which a user is subscribed

Here I have a scenario in which a user can subscribe to a message board and receive all the publications created from that board. There is only one stipulation, which is that the publications created by the subscribed user of each board are deleted. Here is what I came up with:

User class <ApplicationRecord
has_many: subscriptions, dependent :: destroy
finish

Publication class <ApplicationRecord
Belongs to: board
Belongs to: user
finish

Subscription class <ApplicationRecord
Belongs to: user
Belongs to: board
finish

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

I would like to receive comments especially for the way in which I request the subscription publications of the current user in my controller.

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