Rails: get records for has_and_belongs_to_many association -


how rewrite request articles available current_user if articles , templates have has_and_belongs_to_many relationship? feel i'm close can't quite figure out.

current_user.brand.articles.joins(:template).where(:templates => { :id => @template.id }) 

thanks help!

not sure brand association represents , posting models go long way figure out, here's guess:

current_user.brand.articles.joins(:templates).where(:templates => { :id => @template.id }) 

you pluralizing templates in clause not in join.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -