0

I am using the Carrierwave plugin to upload images. It works fine, but if I try to save an image from the controller using

Article.create(:image => 'sample.png')

It doesent save the image as long as carrierwave is mounted, if I un-mount Rails will save the image like normal.. How can I solve this?

tshepang
  • 12,111
  • 21
  • 91
  • 136
jakobk
  • 1,120
  • 1
  • 14
  • 26

1 Answers1

1

This is how I do it, and it works in my seeds at least :

Article.create(:image => File.open(Rails.root.join("app", "assets", "images", "sample.png"))

As you can see, make sure to provide the full path to the file. Explicitly opening the file may help too.

Anthony Alberto
  • 10,325
  • 3
  • 34
  • 38