Reputation: 48443
I have these two models:
user:
has_many :commercials, :dependent => :destroy, :inverse_of => :user
commercial:
belongs_to :user, :inverse_of => :commercials
has_attached_file :image,
:styles => { :medium => "400x400",
:thumb => "50x50>" }
I just uploaded one image, the image is successfully uploaded to Amazon S3 and saved into the database. But how to display it?
I tried:
<%= image_tag @user.adverts(:medium) %>
or
<%= image_tag @user.adverts.medium.url %>
But none of above is working...
Upvotes: 0
Views: 251
Reputation: 34308
Not adverts
, but commercials
? So should it not be something like:
@user.commercials.first.image.url
Upvotes: 1
Reputation: 252
Assuming foo
as the name of the commercial instance
<%= image_tag foo.image.url(:medium) %>
Upvotes: 0