I am using Rails + Devise + OmniAuth + Google OAuth2.
My user model (user.rb) contains:
devise :registerable, :omniauthable, :omniauth_providers => [:google_oauth2]
My routes.rb look like:
Rails.application.routes.draw do
devise_for :users, controllers: { omniauth_callbacks: 'omniauth_callbacks' }
devise_scope :user do
get 'sign_in', :to => 'devise/sessions#new', :as => :new_user_session
post 'sign_in', :to => 'devise/session#create', :as => :user_session
get 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session
end
get 'services', to: 'static_pages#services'
get 'my_account', to: 'my_account#index'
get 'invite', to: 'invite#show'
get 'invite/:id', to: 'invite#show'
root 'static_pages#home'
end
When I go to /sign_in, I get an exception like:
undefined method `session_path' for #<#<Class:0x007f9b7173af28>:0x007f9b713d8da8>
in:
~/.rvm/gems/ruby-2.1.1/gems/devise-3.2.4/app/views/devise/sessions/new.html.erb
in line:
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
If I add :database_authenticatable to user.rb it all starts working, but I want my users to be able to sign-in through Google OAuth2 only, so I don't want :database_authenticable. It looks like session_path is not available for some reason, but I am not sure why and how to make it available.
Thanks, Jen
You need to reboot the rails server. That was the solution for me.