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 8431889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:58:36+00:00 2026-06-10T05:58:36+00:00

I think this question might end up being more rails generic help, but I

  • 0

I think this question might end up being more rails generic help, but I am encountering a problem when trying to delete a paperclip item.

When I click my button, I simply get — No route matches [POST] “/expenses/3” — Perhaps this is the wrong way to call a method?

Thanks in advance, code below.

Here is my view button, I just copied my delete button, and changed the controller method to a new one.

            <%= link_to raw('<i class="icon-trash icon-white"> </i>'), 
                          expense_item, method: :destroy_receipt, 
                          data: { confirm: 'Are you sure delete receipt?' }, 
                          class: "btn btn-mini btn-danger" %>

and in my controller

def destroy_receipt
  @expense = Expense.find(params[:id])
  @expense.receipt.destroy
  redirect_to expense_path
end

my model

class Expense < ActiveRecord::Base
  attr_accessible :amount, :expense_date, :description, :is_billable, :mileage, 
                                :pay_method, :project_id, :type_id, :on_site, :receipt

    belongs_to :project, foreign_key: :project_id
    belongs_to :expense_type, foreign_key: :type_id

  has_attached_file :receipt, :styles => { :medium => "300x300>", :small => "100x100>" }
  • 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-10T05:58:37+00:00Added an answer on June 10, 2026 at 5:58 am

    You are correct, that is not the correct way to go about it.

    The proper arguments to the method: key are POST,GET,PUT,DELETE

    You’d want something like:

    link_to 'hi' , '/urlforhi/:id', :method=>:post
    

    Then you’d have to have a route in routes.rb:

    post '/urlforhi/:id' => 'yourcontroller#hi'
    

    Then in controllers/yourcontroller.rb

    def hi
      @thing = Thing.find(params[:id])
    end
    

    The argument to :method indicates which HTTP VERB to use.

    Note that the DEFAULT method is get, so this would also work:

    link_to 'hi' , '/urlforhi/:id'
    

    Then you’d have to have a route in routes.rb:

    get '/urlforhi/:id' => 'yourcontroller#hi'
    

    or more commonly

    match '/urlforhi/:id' => 'yourcontroller#hi'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I mostly develop using C#, but I think this question might be suitable for
I think this question may end up being a bit subjective so I'm marking
I think this might be an easy question, but I'm just a bit stuck.
You might think that this question is already answered. However, I couldn't find the
Firstly, This might seem like a long question. I don't think it is... The
I think this question has been asked many a times but I've been searching
this question is about style, because i think this is a very common problem
So what might end up being the most stupid question of the day, where
This question ended up being more interesting than I thought it would be, and
This is probably a really easy question, so apologies for not being more challenging!

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.