I am trying to add to a many to many relationship with the following models:
class Account < ApplicationRecord
belongs_to :user
has_many :issues, through: :interests
end
class Issue < ApplicationRecord
has_many :accounts, through: :interests
end
class Interest < ApplicationRecord
belongs_to :account
belongs_to :issue
end
When I try to call the following method in my accounts_controller
def add_issue
issue = Issue.find(params[:id])
@account = current_user.account
@account.interests.create(issue: issue)
end
I get an error reading undefined method 'interests' for #<Account:0x007fe50e23b658>
. What is the proper way to go about posting to a join table?