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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:54:41+00:00 2026-05-13T22:54:41+00:00

I am new to rails. My rails version is 2.3.5. I found usage like:

  • 0

I am new to rails. My rails version is 2.3.5. I found usage like:

In controller, a destroy method is defined and in view, you can use :action => “delete” to fire that method. Isn’t the action name has to be the same as the method name? Why delete is mapped to destroy?

Again, in my controller, I define a method called destroy to delete a record. In a view, I have <%= link_to "remove", :action => 'destroy', :id => myrecord %>. But it never works in practice. Every time I press the remove link, it redirects me to the show view, showing the record’s content. I am pretty sure that my destroy method is:

def destroy
    @myobject = MyObject.find(params[:id])
    @myobject.destroy
    @redirect_to :action = 'index'
end

If I change the method name from destroy to something like remove_me and change the action name to remove_me in the view, everything works as expected.

In the above two weird problems, I am sure there is no tricky routing set in my configuration.

All in all, seems the destroy and delete are mysterious keywords in rails. Can anyone explain this to me?

  • 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-13T22:54:42+00:00Added an answer on May 13, 2026 at 10:54 pm

    You probably set MyObject as a resource in routes.rb. Resources get a couple of routes that don’t directly match the name of the action. When you use an action name that does not match the routes defined by the resource, you’ll get the default route which directly maps to the name of the action.

    I found that this link explains rails’ routing very well. Take a look at the “RESTful routing” section.

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

Sidebar

Related Questions

When setting up a new Rails project (version >= 3) I would like to
I'm reading the new version of Rails Tutorial by Michael Hartl and, since I'm
Running the command generates new rails projects: $ rails generate controller home index The
Rails version 3.0.3, I am new to rails, but been in webdev for a
I worked with rails around the year ago. Now I get the new version
I am working on rails 2.3.4 . As rails new version rails 3 has
I'm new to Rails development, and I'm trying to figure out how to use
I have an almost-new Rails 3.1.0 application, and rspec can't find my examples. duncan@duncan-notebook:~/myapp$
Im new to Ruby On Rails.Im using Ruby version 1.8.7 and Rails version 2.3.8.I
I am new to Rails and I am trying to use omniauth with rails

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.