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

  • Home
  • SEARCH
  • 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 9197111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:00:05+00:00 2026-06-17T22:00:05+00:00

Just starting with Rails. I have a quick question that uses Paperclip and S3

  • 0

Just starting with Rails. I have a quick question that uses Paperclip and S3 for a Rails app that I am building, hosted on Heroku.

I’ve synced everything up so that attachments can be uploaded (both in production and environment) but the only problem is deleting a file from the app/S3. I’ve done a lot of searching but a lot of the implementations involve checkboxes. I’m also running everything through a Files controller to limit access to admins.

I’m using a simple Project model which has_many attachments.

When I click the delete link, I get an error from S3 saying “Error:
MethodNotAllowed. The specified method is not allowed against this resource.
“

Here’s my view:

<% @project.assets.each do |asset| %>
 <%= link_to File.basename(asset.asset_file_name), asset.asset.url %>
 <small>(<%= number_to_human_size(asset.asset.size) %>)</small>
 <%= link_to '[X]', asset.asset.url , confirm: 'Are you sure you want to delete this attachment?', method: :destroy %>

Here’s my destroy action:

def destroy
   @asset = Asset.find(params[:id])
   @asset.destroy
   flash[:notice] = "Attachment has been deleted."
   redirect_to(:back) 
end

The Project model is pretty standard:

class Asset < ActiveRecord::Base
  # attr_accessible :title, :body

  attr_accessible :asset

  belongs_to :project
  has_attached_file :asset, :storage => :s3, :path => (Rails.root + "files/:id").to_s, :url => "/files/:id"
 end

What else am I missing here to get the file removed? Is it something in the model? It all worked well when I wasn’t using S3 and deleted from my SQLite or PG database.

Any help would be much appreciated and thank you!

  • 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-06-17T22:00:08+00:00Added an answer on June 17, 2026 at 10:00 pm

    MethodNotAllowed is an HTTP 405, which means you’re trying to do something S3 doesn’t like. I think the error is with your delete link:

    <%= link_to '[X]', asset.asset.url , confirm: 'Are you sure you want to delete this attachment?', method: :destroy %>
    

    Basically, you’re sending an HTTP destroy to the URL of the file on S3, which should actually go to your Asset controller, and be a :delete.

    Try:

    <%= link_to '[X]', asset, confirm: 'Are you sure you want to delete this attachment?', method: :delete %>
    

    In your controller you should then handle deleting the asset:

    def destroy
       @asset = Asset.find(params[:id])
       @asset.destroy
       flash[:notice] = "Attachment has been deleted."
       redirect_to(:back) 
    end
    

    Hope this helps!

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

Sidebar

Related Questions

I am just starting to learn Ruby on Rails and have a newbie question
Just starting out with rails and I have a question. My grasp on associations
I'm just starting out with Rails and ActiveRecord. I feel that anything I want
I have a Rails app on Heroku with code to send a UDP packet
Just starting to use Ruby on Rails to see what its like. I have
My Rails app is starting to need complicated queries. Should I just start using
Just starting to learn Ruby on Rails. I'm using RoR 3. I have read
I am just starting with rails and I have a very simple case. I
I am just starting with Ruby on Rails, because I was told that it
I'm building a Rails app that needs some data visualization. What is a good

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.