I have an existing Rails 5.1 application which already contains a custom user controller.
As I was following the instructions to install Spree
, I installed the spree_auth_devise
gem and ran the migrations and other install commands as advised on the readme page. As I began working with the gem I found that there was an issue with my User class, and this - of course - was because I had installed the devise gem
when I am not using devise.
I have attempted to follow the instructions on how to set up a custom user model when not using devise, but after following these instructions and removing the spree_auth_devise
I am unable to launch the site.
When I run the site with the gem installed, my custom routes for "login" etc, do not work. They point to the path where spree is installed and not that defined in my routes.rb.
I'm not sure what to do to remove the gem and get my user model working with spree. Any help is appreciated. I'm not sure what details or code to provide other than this as there are many files affected by this. I will post anything you feel may help.
UPDATE: Per the comment below, here are the spree-relevant portions of my routes.rb. Let me know if you need anything else:
mount Spree::Core::Engine, at: '/store'
get 'login' => 'sessions#new'
get 'signup' => 'users#new'
delete 'logout' => 'sessions#destroy'
post 'login' => 'sessions#create'
UPDATE 2 I get this error when I try to launch the server or run rake db:migrate...
Exiting
/Users/user/sites/site/app/controllers/application_controller.rb:8:in `<class:ApplicationController>': uninitialized constant Spree::AuthenticationHelpers (NameError)
from /Users/user/sites/site/app/controllers/application_controller.rb:1:in `<top (required)>'
Based on your information, try this:
Remove config/initializers/devise.rb
if you haven't done it
remove any devise
related code from your routes.rb
Might look similar to this:
devise_for :users, controllers: {
confirmations: 'users/confirmations',
passwords: 'users/passwords',
registrations: 'users/registrations',
sessions: 'users/sessions',
unlocks: 'users/unlocks'
}
Check if there are is any code related to devise
/spree_auth_devise
Might look like this in your User
model:
devise :database_authenticatable, :registerable
Or in your ApplicationController
or any other controller (git grep it):
before_action :authenticate_user!
Rollback your database changes (set STEP and RAILS_ENV appropirately):
rake db:rollback STEP=1 RAILS_ENV=development
If nothing helps, try a git revert or git reset
Regarding your error uninitialized constant Spree::AuthenticationHelpers
This module is defined in the spree_auth_gem
here and also gets included to your ApplicationController
in the engine.
If you did setup spree by this guide remove include Spree::AuthenticationHelpers
from your ApplicationController
.
Thes includes below might also be unnecessary. I would remove them 1 by 1 and see if your app still works:
include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Common
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::Store
helper 'spree/base'