Problem with paperclip after inner join

2

I have 2 tables ( members and pics ), and I just made a inner join and now when I send a call to the image in the view, it does not send me the url of the image anymore.

Before the join it showed the data like this.

%p=pic.member.username
=image_tag pic.image.url(:thumb)

... and after the join I show them that way.

%p=pic.username
=image_tag ?

... and in the image I do not understand how to compose it, because if I put it as the example of before, it makes me a lot of questions.

How to get the url from the image after join ?

    
asked by Angel Mendez 26.10.2016 в 20:04
source

1 answer

0

As it says hcarreras, it would be convenient to see how you do the inner join.

If it is with a scope and you have 'image' as a different model (not as an attribute of the model 'member' and 'pics') you have to do an include. For example:

# image.rb
class Image < ActiveRecord::Base
   attr_accessible :title, :file
   has_attached_file :file, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
end

Then your scope would be something like this:

Member.joins(:pics).include(:images)

Please, give it a try and comment if it works like this.

    
answered by 27.10.2016 в 10:57