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

remove_ does not work #481

Closed
elianderson opened this issue Oct 6, 2011 · 3 comments
Closed

remove_ does not work #481

elianderson opened this issue Oct 6, 2011 · 3 comments

Comments

@elianderson
Copy link

trying to use a checkbox to remove an image would result in

Fog::Storage::Rackspace::NotFound

Here is the front-end

  <div class="group">
      <%= f.label "Remove Image" %>
      <%= f.check_box :remove_background_image%>
   </div>
  <div class="group">
    <%= f.label :background_image %>
    <%= f.file_field :background_image, :class => :file_field %>
  </div>

to get around this I had to add the following methods to my model:

   def remove_background_image!
      begin
        super
      rescue Fog::Storage::Rackspace::NotFound
      end
    end
    def remove_background_image
      begin
        super
      rescue Fog::Storage::Rackspace::NotFound
      end
    end
    def remove_previously_stored_background_image
      begin
        super
      rescue Fog::Storage::Rackspace::NotFound
        @previous_model_for_background_image = nil
      end
    end

If I am just missing something please let me know.

@trevorturk
Copy link
Contributor

Can you provide a small sample application that we can review? It's hard to tell what might be going wrong just from the information provided here. Thanks!

@scottwb
Copy link
Contributor

scottwb commented Oct 28, 2011

I wrote up something in the wiki about similar issues a while back: https://github.com/jnicklas/carrierwave/wiki/How-To%3A-Silently-ignore-missing-files-on-destroy-or-overwrite after a discussion about it on the Google Group: http://groups.google.com/group/carrierwave/browse_thread/thread/bc6a71c4c2067af/af68d377e4b4e57d?lnk=gst&q=scottwb#af68d377e4b4e57d

It's hard to tell without more details about your repro scenario, but my guess is that you are removing an image that was never set in the first place. The references above discuss my problems that were similar to yours in this respect, and conclude that the solution, which is very similar to yours, was the way to go.

@elianderson
Copy link
Author

Sorry for the late response, but the issue occurred when I tried to delete the image after it was set. It seemed like it was deleting the actual image off of the cdn first - then throwing an error when trying to remove the relationship between the image and the object. I am using active record if that helps. I got around this issue by creating a separate model for my upload and deleting the entire object opposed to just the image relationship from the object. If I get some time later this week i will try to recreate the issue in a small demo app.

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