Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6016471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:59:14+00:00 2026-05-23T02:59:14+00:00

Using Carrierwave 0.5.4 on Rails 3.1 RC4. In Rails console, I do: @foo.attachment returns:

  • 0

Using Carrierwave 0.5.4 on Rails 3.1 RC4.

In Rails console, I do:

@foo.attachment

returns:

=> http://cdn.site_name.com/uploads/users/2/banners/banner.png 

However:

@foo.remove_attachment!

returns:

 => [:remove_versions!] 

The record still remains in the DB, BUT the file is removed in the S3 bucket.

What is going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:59:15+00:00Added an answer on May 23, 2026 at 2:59 am

    Ahhh, after further investigating. This is what I have found out. remove_attachment! is meant to remove the image from S3, but is not meant to remove the uploader object in the attachment column, in the db. This is the normal behavior of Carrierwave.

    Jnicklas provided a test spect at https://github.com/jnicklas/carrierwave/commit/ecabc618d0fce22c1931c6d2eb134886e3b60e4c which uses @doc.remove_image = true. This is the key, because when one submits a form to remove an attachment / image / photo / whatever. They normally include a check box that looks like:

    <input type="checkbox" value="1" name="user[remove_attachment]" id="user_remove_attachment">
    

    Which can be rendered with the helper tag as:

    <%= f.check_box :remove_attachment %>
    

    If the check box is clicked and the form is submitted. Params will look something like:

    {"utf8"=>"✓", "_method"=>"put", ....., "user"=>{"remove_attachment"=>"1"}, "controller"=>"das....}
    

    Rails will interpret this as @user.remove_attachment = true to clear the db column and also trigger .remove_attachment! to remove the file from S3.
    Also worth noting. If attr_accessible is defined in the User model. Then it must have :attachment, :remove_attachment as well.

    Hope this helps someone out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the carrierwave gem (http://github.com/jnicklas/carrierwave) for ruby on rails. How do I
I'm using Carrierwave in my Rails app to handle image uploads. When I configure
I am using the carrierwave gem to manage file uploads in my rails 3
Rails noob here. I am using carrierwave in a rails 3 app so users
I'm making a rails 3.1 app using carrierwave to upload files to aws s3.
I am using the carrierwave gem with Rmagick in a Rails app. I've set
My Rails app uses carrierwave to manage image uploads. I have a watermark version
Using Google Maps InfoBox - http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html Currently the map will scroll - pan control
Just started using carrierwave with Rails and things have been going smoothly with one
In my rails 3 application, I am using carrierwave gem (version 0.5.6). I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.