From 17210c3fd3d4ca862287c85586f76bb779907240 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 23 May 2012 10:47:22 +1000 Subject: [PATCH] Put user class extensions inside a to_prepare block --- core/config/initializers/user_class_extensions.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 -