0

I am using Carrierwave to upload the imgae, i have used in one model, now i want to use carrierwave to upload images in other model within same app,

i have create uploader as,

$ rails g uploader image2
$ rails g migration add_image_to_products image2:string

in model

attr_accessible :gallery_id, :name, :image2
mount_uploader :image2, ImageUploader

it uploads the file i have check in the folder, but not able to display the image,

image_tag product.image_url.to_s

Got this error

undefined method `image_url' for #<Product:0x49a3e68>

Note: In the same app i have used the Carrierwave and able to display the image as wel for that model which is Category, but have problem with Product model, i am trying to using carrierwave to upload files for Product model..

4

1 回答 1

1

shouldn't it be

image_tag product.image2_url.to_s?

beacause you are using the uploader called image2!

于 2012-05-02T12:13:56.000 回答