Association named ‘spree_roles’ was not found; perhaps you misspelled it?

(This is a legacy post from the old website.)

Association named ‘spree_roles’ was not found; perhaps you misspelled it?

I ran into this error while developing an extension for Spree 1-3-stable
and writing request specs to run on the dummy test app generated via bundle exec rake test_app.
You may have also run into this error on a normal Spree app if you
installed Spree in your Rails apps using just your Gemfile and bundler
instead of spree install <my_store>.

Regardless, this is an issue with Spree not setting the correct user
model in the spree initializer during install. To correct this, update config/intializers/spree.rb to use:

Spree.user_class = "Spree::User"

instead of

Spree.user_class = "Spree::LegacyUser"

If you’re having this issue with the dummy test app spec/dummy, just do the same for the dummy app’s initializer: spec/dummy/config/initializers/spree.rb

For more information:
See the issue for dummy test_app:https://github.com/spree/spree/issues/1966
See the issue for regular Spree:https://github.com/radar/spree_auth_devise/issues/1

Leave a Reply

Your email address will not be published. Required fields are marked *