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"
My problem was pretty simple in the end. I included spree_auth_devise when I shouldn't have. Here are the correct steps: