Reputation: 701
I'm trying to use carrierwave to add profile images to a user model that's handled by devise. I've used carrierwave before with no problems but this time, when I go to start the rails server, I get the error:
/var/lib/gems/1.9.1/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:46:in `uploader_option': undefined method `validate_integrity' for :ImageUploader:Symbol (NoMethodError)
There's very little information about this out there but I did read that you could ignore some errors using :ignore_integrity_errors. After trying a few times (and getting a lot of syntax errors) I finally settled on passing that in like so:
mount_uploader :profile_image, :ImageUploader, :options => {:ignore__integrity_errors => true}
I still think my syntax is incorrect because the NoMethodError persists. Any help at all on this matter would be much appreciated!
EDIT
I reverted to the commit before I started working with carrierwave, started my server, and tried again. In my browser I'm now getting the error:
uninitialized constant CarrierWave
on this line
class ImageUploader < CarrierWave::Uploader::Base
and this error apparently happens when the routes are loaded. I'm really confused about this, I have the gem in my Gemfile and I ran bundle install.
Upvotes: 1
Views: 462
Reputation: 15219
There are a couple of things going on here. First, the reason you're seeing the uninitialized constant CarrierWave
error is probably just a consequence of not having restarted the server or something silly like that. If you've properly included it in the Gemfile and bundled, you should be fine.
To your original issue, though, there are three problems. The first is that you're passing a symbol as the uploader, and you need to pass the class. So you should pass ImageUploader
, not :ImageUploader
. The second issue is that you must pass the options hash directly to the uploader, not inside a parent hash with an options
key. The third problem is that you've included an additional underscore in the ignore_integrity_errors
symbol. So you should be using this:
mount_uploader :profile_image, :ImageUploader, ignore_integrity_errors: true
Upvotes: 1
Reputation: 1
It would help to know what version to rails you are using. I've had this issue before but a server restart helped out.
Also, it looks like others had this issue. Maybe try doing what some of the users did here: https://github.com/carrierwaveuploader/carrierwave/issues/399
Upvotes: 0