No route matches [GET] "/session"

The signout does not work. Here is the view:
<%= link_to ‘Sign out’, session_path, method: :delete %>
The following is generated:
Sign out
Unfortunately this results in a get instead of a delete. I have Rails 4 gem installed but have specified Rails 3.1.12

Rake routes:

   root GET    /                      {:controller=>"homes", :action=>"show"}
session POST   /session(.:format)     {:action=>"create", :controller=>"sessions"}

new_session GET /session/new(.:format) {:action=>“new”, :controller=>“sessions”}
DELETE /session(.:format) {:action=>“destroy”, :controller=>“sessions”}
users POST /users(.:format) {:action=>“create”, :controller=>“users”}
new_user GET /users/new(.:format) {:action=>“new”, :controller=>“users”}

Gemfile:
source ‘http://rubygems.org

gem ‘rails’, ‘3.1.12’

gem ‘sqlite3’
gem ‘strong_parameters’, ‘0.2.0’
gem ‘monban’

group :assets do
gem ‘sass-rails’, ‘~> 3.1.5’
gem ‘coffee-rails’, ‘~> 3.1.1’
gem ‘uglifier’, ‘>= 1.0.3’
end

gem ‘jquery-rails’

group :test do

Pretty printed test output

gem ‘turn’, ‘~> 0.8.3’, :require => false
end

@Ray_Hooker, I believe this is caused by the strong_parameters gem. Try removing it from your gemfile as well as the references to it in application.html.erb.

bundle and restart your server and the link should now send a DELETE request

EDIT strong_parameters is a gem that handles permissions to set attributes on an object. I meant turbolinks here.

I removed strong_parameters, did a bundle and a restart. Unfortunately that does not solve the problem. It still does a get.

:facepalm: I meant turbolinks, not strong_parameters (you want that). There is probably a reference to it in application.html.erb, application.js, and possibly still in your Gemfile

Joel, I suspect you are right to look at Javascript but there is no turobolinks. There is only jquery, jquery_ujs and tree. OTOH as I tried share before, the link_to is translated to:

…<.a href=“/session” data-method=“delete” rel=“nofollow” >Sign out</a>

So note that it is an html data item. I believe that the Rails routing is supposed to use that… but I don’t see evidence that it was passed in the get request. I am not sure what whether there is a Javascript helper needed to make that happen such as for rails.js and the remote-data tag.

Ray
application.js
//= require jquery
//= require jquery_ujs
//= require_tree .

application.html.erb (header)

Shouter <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %>

gemfile…
source ‘http://rubygems.org

gem ‘rails’, ‘3.1.12’

gem ‘sqlite3’
gem ‘strong_parameters’, ‘0.2.0’
gem ‘monban’, ‘0.0.6’

group :assets do
gem ‘sass-rails’, ‘~> 3.1.5’
gem ‘coffee-rails’, ‘~> 3.1.1’

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem ‘therubyracer’

gem ‘uglifier’, ‘>= 1.0.3’
end

gem ‘jquery-rails’

group :test do

Pretty printed test output

gem ‘turn’, ‘~> 0.8.3’, :require => false
end

So that I could continue with the video, I did update the routes to add a get route:
get “sessions/signoutsession”
I added a signoutsession method to sessions to delete the session and updated the view to call it. I still need to find the problem since this is not how it should be.

Ray

Problem solved. It was a buggy version of Rails. I upgraded to 3.2.16 (from 3.1.12) and the problem went away :smile: