Reputation: 6981
How would I rewrite this request to get the articles
available to the current_user
if articles
and templates
have a has_and_belongs_to_many
relationship? I feel like I'm close but I can't quite figure it out.
current_user.brand.articles.joins(:template).where(:templates => { :id => @template.id })
Thanks for your help!
Upvotes: 1
Views: 136
Reputation: 3911
Not sure what the brand
association represents and posting your models would go a long way to help figure this out, but here's a guess:
current_user.brand.articles.joins(:templates).where(:templates => { :id => @template.id })
You were pluralizing templates
in the where clause but not in the join.
Upvotes: 1