I have model Company and company has mounted carrierwave uploader Logo.
class Company < ActiveRecord::Base
mount_uploader :logo, LogoUploader
Images upload works, but I have an issue with update_attributes. When user wants to update only description or title of the company, but not to upload new image - filename value in DB is still being changed every time. Here is a simple example:
1.9.3-p545 :004 > a = Company.last
1.9.3-p545 :005 > a.update_attributes(:title => "test title 2")
(0.4ms) BEGIN
Company Exists (0.9ms) SELECT 1 AS one FROM `companies` WHERE (`companies`.`title` = BINARY 'test title 2' AND `companies`.`id` != 37) LIMIT 1
Company Load (0.7ms) SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 37 LIMIT 1
(0.7ms) UPDATE `companies` SET `title` = 'test title 2', `logo` = '1396206630_1f288be4.jpg', `updated_at` = '2014-03-30 19:10:30' WHERE `companies`.`id` = 37
(8.1ms) COMMIT
=> true
Why logo is being updated here with new value even the new value was not given? How to avoid this?