Permalink
Browse files

Put user class extensions inside a to_prepare block

  • Loading branch information...
1 parent 04b84e3 commit fab8d3d6497d03735df7273c79e455680108b623 @radar radar committed May 23, 2012
Showing with 8 additions and 7 deletions.
  1. +8 −7 core/config/initializers/user_class_extensions.rb
View
15 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
-

0 comments on commit fab8d3d

Please sign in to comment.