Hello, I have the following in my controller to obtain a project's team members:
@project = Project.find(params[:project_id])
@teammembers = @project.permissions.includes(:user).joins(:user, :role).select("*")
The problem here is that the user's table belongs_to the instance model. And the instance model has a name, which I want in @teammembers.
I tried adding this in like follows:
@teammembers = @project.permissions.includes(:user).joins(:user, :role, :instance).select("*")
but that errors with: "Association named 'instance' was not found; perhaps you misspelled it?"
Which kinda makes sense since Permissions includes (user_id, role_id, and project_id)
Suggestions on how I can join the instance table for instance.name in this query so my view doesn't hit the db so many times to look up the instance.name?
Thanks
Cleaned it up