Ruby on Rails Tuesday, April 1, 2014

@Abdulsattar Mohammed, 

There are no javascript errors in the console and jquery-ujs appears to be loaded (see head of page source below). 

<head>
<title>Blog</title>
<link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/comments.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/posts.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/welcome.css?body=1" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/comments.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/posts.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/welcome.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/application.js?body=1"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="sTwrvSyBQ0rGRescsUYaL8JJ9LLcUfkOP6JMGcXiccw=" name="csrf-token" />
</head>

I have also checked to make sure the issue isn't something as small as a popup blocker. 

Thanks,

Peter


On Monday, 31 March 2014 17:02:09 UTC+1, Peter Heylin wrote:
Hi All,

I am new to RoR and I am writing a small blog application. I have added a Destroy / Delete link to the post index, but when I click this delete link the show action is fired. The log seems to confirm this: 

Started GET "/posts/2" for xxx.xxx.xxx.xxx at 2014-03-31 15:51:03 +0000
Processing by PostsController#show as HTML
  Parameters: {"id"=>"2"}
  Post Load (0.1ms)  SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1  [["id", "2"]]
  Comment Load (0.1ms)  SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?  [["post_id", 2]]
  Rendered posts/show.html.erb within layouts/application (9.0ms)
Completed 200 OK in 120ms (Views: 117.3ms | ActiveRecord: 0.2ms)

My destroy method in the controller is: 

def destroy
    @post = Post.find(params[:id])
    @post.destroy

    redirect_to posts_path
end


The code in the index view is: 

       <td><%= link_to 'Destroy', post, method: :delete, data: {confirm: 'Are you sure?'}  %></td>

Would anyone have any idea what I might be missing here? 

Any help appreciated

Peter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a98d9410-cbef-4fac-8aef-28751a39782b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment