html5 - Rails link_to method: :delete -


i sorry asking may remedial question, in learning rails trying follow along note note in tutorial:

http://guides.rubyonrails.org/getting_started.html

i posted similar question tutorial last night , got prompt response helped me significantly, hoping same. thank in advance.

section 5.14: deleting posts

i instructed add delete link index.html.erb page

<h1>listing posts</h1> <table>   <tr>     <th>title</th>     <th>text</th>     <th></th>     <th></th>     <th></th>   </tr>  <% @posts.each |post| %>   <tr>     <td><%= post.title %></td>     <td><%= post.text %></td>     <td><%= link_to 'show', post_path %></td>     <td><%= link_to 'edit', edit_post_path(post) %></td>     <td><%= link_to 'destroy', post_path(post),                     method: :delete, data: { confirm: 'are sure?' } %></td>   </tr> <% end %> </table> 

which generates:

<td><a data-confirm="are sure?" data-method="delete" href="/posts/1" rel="nofollow">destroy</a></td> 

it looks ok me, when click on link neither confirmation nor directed delete action. generates http action

request url:http://localhost:3000/posts/1  request method:get  status code:200 ok  

rails: 4, ruby: 2, 64 bit windows 8, chrome: version 28.0.1500.72 m

thank again


adding application.html.erb

<!doctype html> <html> <head>   <title>listing</title>   <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>   <%= javascript_include_tag :application %>   <%= csrf_meta_tags %> </head> <body>  <%= yield %>  </body> </html> 

which yielded error:

execjs::runtimeerror in posts#index showing c:/ruby-projects/listing/app/views/layouts/application.html.erb line #6 raised:

(in c:/ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-1.3.0/lib/assets/javascripts/turbolinks.js.coffee) extracted source (around line #6): 3 4 5 6 7 8 9 listing <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag :application %> <%= csrf_meta_tags %>

rails.root: c:/ruby-projects/listing

application trace | framework trace | full trace app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___567964991_28724900' request

parameters:

none


application.js

//= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . 

make sure have

//= require jquery //= require jquery_ujs 

into application.js file , application.js file included view/layout/application.html.erbfile


Comments