jakobk
jakobk

Reputation: 1132

Rails / image not being saved when Carrierwave is mounted

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?

Upvotes: 0

Views: 464

Answers (1)

Anthony Alberto
Anthony Alberto

Reputation: 10395

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.

Upvotes: 1

Related Questions