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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:57:11+00:00 2026-05-22T22:57:11+00:00

I am trying to do a simple deletion of a record in the database.

  • 0

I am trying to do a simple deletion of a record in the database.

<b> <%= button_to "Cancel your invitation", { :controller=>"invites", :method => 'destroy', :id => invite.id },
:confirm => "Are you sure you want to delete this invite?" %></b>

I specify the the controller because I am doing this action from a User view.

When I click the button, it creates a blank entry for a new record. So why would it use a create method when I specified a destroy one?

Some more into:
My config/routes is as simple as can be:

resources :invites

My controller is quite basic too:

  def create
    @invite = Invite.new(params[:invite])
    if @invite.save
      redirect_to current_user
    else
      redirect_to root_path
    end
  end



  def destroy
    Invite.find(params[:id]).destroy
    redirect_to current_user
  end
  • 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-22T22:57:12+00:00Added an answer on May 22, 2026 at 10:57 pm

    You misused the methods. It should be:

    <b>
      <%= button_to "Cancel your invitation", invite, :confirm => "Are you sure you want to delete this invite?", :method => :delete %>
    </b>
    

    There are 2 points.

    1) For resources :invites, the destroy method needs delete. Without passing :method => :delete to button_to would by default use :method => :post, which is the create method. That’s why you created a new record instead of destroying it.

    2) As you are using resources, you have better choice for the route instead of {:controller => "invites", :action => "destroy", :id => invite.id} (note that it was :action)

    You could use invite_path(invite) or just invite just like my example above. With the :method => :delete this gives you the destroy method. (so with :post for create, :put for update)

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

Sidebar

Related Questions

I am trying a simple Extension Method example and am unable to increment or
Trying to simple update a row in an SQLiteDatabase Database. I can insert records
I am learning and trying simple example using node.js and mongoskin. here is my
I am trying something simple as creating a text file and then send it
I am trying this simple tutorial from oracle : http://www.oracle.com/technetwork/java/socket-140484.html (the Example 1 ).
Hi I am trying out simple rollover images for a site I am currently
Trying to make simple minesweeper game in python, but have one problem. I have
Trying to do simple header for website, [image][text][splitted horizontal section]: <div style=width: 930px;> <div
I am trying to make simple encryption algorithm .My aim is to translate abc
I am trying something very simple, but for some reason it does not work.

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.