0

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...

4

2 に答える 2

1

ではありませんadvertscommercials?したがって、次のようなものであってはなりません。

@user.commercials.first.image.url
于 2013-01-06T15:38:06.107 に答える
0

foo商用インスタンスの名前として想定

<%= image_tag foo.image.url(:medium) %>
于 2013-01-06T15:35:04.293 に答える