diff --git a/core/config/initializers/user_class_extensions.rb b/core/config/initializers/user_class_extensions.rb index 7bed68c4181..3481abf898f 100644 --- a/core/config/initializers/user_class_extensions.rb +++ b/core/config/initializers/user_class_extensions.rb @@ -1,11 +1,12 @@ -if Spree.user_class - Spree.user_class.class_eval do - has_and_belongs_to_many :roles, :join_table => 'spree_roles_users' +Spree::Core::Engine.to_prepare do + if Spree.user_class + Spree.user_class.class_eval do + has_and_belongs_to_many :roles, :join_table => 'spree_roles_users' - # has_spree_role? simply needs to return true or false whether a user has a role or not. - def has_spree_role?(role_in_question) - roles.any? { |role| role.name == role_in_question.to_s } + # has_spree_role? simply needs to return true or false whether a user has a role or not. + def has_spree_role?(role_in_question) + roles.any? { |role| role.name == role_in_question.to_s } + end end end end -