I have model Issue that has_many :comments, model Comment that has_many :assets, as: :assetable, class_name: 'Comment::Asset', and model Asset that belongs_to :assetable, polymorphic: true
I need to get all the assets of the particular Issue. My firt implementation is as following:
comments = Comment.where(issue_id: issue.id).ids
assets = Asset.where(assetable_id: comments)
However, it is obviously far from perfect. I believe, that this sould be rewritten using joins or something like this, but I fail to wrap my head around it and find a solution. What would you recommend?
