I am working through the Getting Started tutorial (creating a Blog) and the link_to Destroy is not functioning properly. In the terminal it always interprets it as #SHOW. <
include below line in js
//= require jquery_ujs
include gem:
gem 'jquery-rails'
Destroy Link:
<%= link_to "Logout", destroy_user_session_path %>
I had the same problem as Barry. Make sure you're copy/pasting correctly in your /app/views/index.html.erb file and inspect the html that is rendered.
I had the same issue, for rails 4.2.X. Checked all my javascript files but could not make it work. if u look closely at the server request u will be missing 'authenticity_token' in the params, so user gets logged out. In rails 4.1 and above u have to use button_to instead of link_to
Started GET "/posts/4" for 127.0.0.1 at 2013-08-09 13:45:20 -0600
This is the problem. The delete link is using GET http verb even though you used method: delete
in your link.
Check out the following SO thread
Try this
<%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
I had same problem. In my case, a i had change \app\views\layouts\application.html.erb file from
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
to
<%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>
to avoid my very first Rails problem. But it apparently mangled JavaScript execution and caused Destroy issue. Therefore rollback your \app\views\layouts\application.html.erb file to its original state, and treat this problem as here
Rails ExecJS::ProgramError in Pages#home?
in evedovelli answer (about coffeescript gem in windows).