Search code examples
ruby-on-railsruby-on-rails-4carrierwave

Bypass Carrierwave uploader when saving to model


I have the Carrierwave gem installed in my Rails 4 app. I've created an Event model where an image location is saved to the model using the uploader. This works fine for image upload.

This is my code in the model attr_accessor :image mount_uploader :image, ImageUploader

Now I want to make new events without uploading another image. I just want to save the image location in the new event. But because the uploader is in place when I try to save just the image location in a new Event it doesn't save.

How do I bypass this uploader and just save the image location?


Solution

  • The update_column method allowed me to directly change this in the database. And the square bracket notion allowed me to directly read the column without the Carrierwave object wrapper.

    Like this: event.update_column(:image, original_event["image"])