Spree_auth_devise seed fails with Unknown column 'roles.name'

355 Views Asked by At

I am installing Spree in conjunction with spree_auth_devise. I am running into a problem when creating an admin user either through seeding or by running the command bundle exec rake spree_auth:admin:create

Here is the full error message:

ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'roles.name' in 'where clause': SELECT COUNT(DISTINCT `spree_users`.`id`) FROM `spree_users` LEFT OUTER JOIN `spree_roles_users` ON `spree_roles_users`.`user_id` = `spree_users`.`id` LEFT OUTER JOIN `spree_roles` ON `spree_roles`.`id` = `spree_roles_users`.`role_id` WHERE `roles`.`name` = 'admin'

I have followed these steps to install spree_auth_devise and can confirm the migrations are created and run successfully:

bundle exec rake spree_auth:install:migrations
bundle exec rake db:migrate
bundle exec rails g spree:auth:install

I receive the error as a result of running this line in seeds.rb:

Spree::Auth::Engine.load_seed if defined?(Spree::Auth)

I receive the same error when running:

bundle exec rake spree_auth:admin:create

I have also followed these intructions:

At this point, if you are using spree_auth_devise you will need to change this line in config/initializers/spree.rb:

Spree.user_class = "Spree::LegacyUser"

To this:

Spree.user_class = "User"

1

There are 1 best solutions below

0
On

My problem was pretty simple in the end. I included spree_auth_devise when I shouldn't have. Here are the correct steps:

gem 'spree', github: 'spree/spree', :branch => '2-3-stable'

$ bundle install

$ rails g spree:install --migrate=false --sample=false --seed=false

config/initializers/spree.rb by changing this line: Spree.user_class = "Spree::User" to this: Spree.user_class = "User"

$ rails g spree:custom_user User

$ rake db:migrate