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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:48:52+00:00 2026-05-19T15:48:52+00:00

I am not able to find the right way to destroy a record. I

  • 0

I am not able to find the right way to destroy a record. I feel like such a complete newb.

Here are the routes pertaining to the controller (output from rake routes):

    contents GET    /admin/contents(.:format)                   {:controller=>"contents", :action=>"index"}
    contents POST   /admin/contents(.:format)                   {:controller=>"contents", :action=>"create"}
 new_content GET    /admin/contents/new(.:format)               {:controller=>"contents", :action=>"new"}
edit_content GET    /admin/contents/:id/edit(.:format)          {:controller=>"contents", :action=>"edit"}
     content GET    /admin/contents/:id(.:format)               {:controller=>"contents", :action=>"show"}
     content PUT    /admin/contents/:id(.:format)               {:controller=>"contents", :action=>"update"}
     content DELETE /admin/contents/:id(.:format)               {:controller=>"contents", :action=>"destroy"}

What is getting me is the bottom line does not look any different than the get and put.

Here is the link:

<%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :delete %>

also tried:

<%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :destroy %>

and the output is:

<a href="/admin/contents/1400" data-confirm="Are you sure?" data-method="destroy" rel="nofollow">Destroy</a>

Can someone spot what I am doing wrong here? :-/


edit

I did not intially have rails.js loading. I do now.

Here is the contents of my destroy action:

def destroy
  @content = Content.find(params[:id])
  @content.destroy

  respond_to do |format|
    format.html { redirect_to(contents_url) }
    format.xml  { head :ok }
  end
end

I am deleting from the content index, like so:

<% @contents.each do |content| %>
  <tr>
    <td><%= content.name %></td>
    <td><%= link_to 'Show', content %></td>
    <td><%= link_to 'Edit', edit_content_path(content) %></td>
    <td><%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :destroy %></td>
  </tr>
<% end %>
</table>
  • 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-19T15:48:52+00:00Added an answer on May 19, 2026 at 3:48 pm

    The URL looks the same because it is the same. The difference lie within the request method. Your Rails app knows to separate GET, PUT and DELETE requests–even if they are made to the same URL–and route the request to the right action.

    However, not all browsers/web servers support all of these methods, so Rails rely upon unobtrusive JavaScript (ujs) to “fake” some of the requests–more specifically, PUT and DELETE. Because of this, you’ll need to include one of the bundles for Rails apps (the Prototype comes by default; you can get the jQuery version through this gem). You can find out more through the README (and of course the source) of the jQuery ujs.

    If you’re experiencing issues, it’s probably because you don’t have the necessary ujs. It could also be that you haven’t included the csrf_meta_tag in your html header.

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

Sidebar

Related Questions

I've searched and not been able to find the right way of doing what
I am not able to find a way to set TransactionIsolation in ejb. Can
I have not been able to find a way to join 4 or more
I need to show activity indicator but not able to find the right approach,
I am not able to find a similar question else where on this site,
I am not able to find the reason of a crash in my iphone
First of all: I am not able to find out the proper Title of
I am not sure why but jQuery find function is not able to find
I have a simple question but was not able to find an answer on
It is a simple question to which I am not able to find the

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.