I am using CarrierWave with Rails 3.1. I am getting the following error message when I submit the form (trying to upload an image):
Error Message:
Ac
Make sure you use - mount_uploader :image, ImageUploader in your model like here -
class CarImage < ActiveRecord::Base
belongs_to :car
mount_uploader :image, ImageUploader
end
Regards
Robbie
I came across this post because I had the same error you described, but restarting the server didn't resolve it (as suggested by other answers). In my case, the problem was caused because I used mount_uploader
before attr_accessible
. By switching them I solved the problem.
I had a similar problem. Solution was changing:
attr_accessible :title, :body, :user_id, :draft, :post_type, :image
belongs_to :user
mount_uploader :image_url, ImageUploader
to:
attr_accessible :title, :body, :user_id, :draft, :post_type, :image_url
belongs_to :user
mount_uploader :image_url, ImageUploader
Your image uploader class was not loaded into your current rails server thread. Reload rails server and it should work fine =).
Make sure in your model:
mount_uploader :image, ImageLoader
Remember that :image must be the string/text type.
I experienced the some problem and the cause is (probably always) that the UploadedFile object has been sent to the attribute carrierwave was mounted on. The db adapter cannot serialize this object and will therefore throw this error.
Make sure that:
write_attribute
to write the uploaded file (which was the cause of my problem). Use the accessor instead: model.send('image=', params[:model][:image])
. Uglier, but better.