Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using carrierwave-mongoid with fog storage results in error #168

Open
vertis opened this issue Sep 2, 2016 · 1 comment
Open

Using carrierwave-mongoid with fog storage results in error #168

vertis opened this issue Sep 2, 2016 · 1 comment

Comments

@vertis
Copy link

vertis commented Sep 2, 2016

I am using a combination of carrierwave-mongoid (ORM support) and fog-google for the actual storage of the images.

When uploading a new image Carrierwave tries to delete the old image (that doesn't exist).

DEBUG -- : [httplog] Sending: DELETE http://www.googleapis.com:443/storage/v1/b/<snip bucket>/o/development%2Fuser%2Flogo%2F57c64d6cf0fd5a0b4d46ffcb%2F_new_

This happens because carrierwave-mongoid has:

def #{column}_will_change!
   changed_attributes["#{column}"] = '_new_'
end

Carrierwave ends up with the 'new' when calling

# lib/carrierwave/mount.rb
def remove_previously_stored_#{column}
  _mounter(:#{column}).remove_previous(*@_previous_changes_for_#{column})
end

Specifically the before variable in def remove_previous(before=nil, after=nil) (found in lib/carrierwave/mounter.rb is not nil or blank.

I'm not sure how to fix this properly, it looks like the 'new' is there for embedded document support, otherwise I would have just sent a pull request.

@jnfeinstein
Copy link

jnfeinstein commented Aug 3, 2018

I'm experiencing the same issue using GridFS. I've tracked the issue down to this line. It appears that nil, the previous value, is always being overwritten by "_new_" via ||. When I remove this it works fine. Is there a reason why it has to use replace nil with "_new_"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants