Reputation: 383
How do I combine for example all the Tag.has_many :images, through: :taggings
from a bunch of Tag
s?
Something around this unless theres something simpler:
images = ???
Tag.where("name in (?)", tag_params).each do |tag|
images = images.merge(tag.images)
end
Upvotes: 0
Views: 47
Reputation: 51151
How about:
images = Image.joins(:tags).where(['tags.id in (?)', tag_params])
?
Upvotes: 1