Skip to content

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

@vertis

Description

@vertis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions