Skip to content

Commit

Permalink
Put user class extensions inside a to_prepare block
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Jun 20, 2012
1 parent bd52468 commit 17210c3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/config/initializers/user_class_extensions.rb
Original file line number Diff line number Diff line change
@@ -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 17210c3

Please sign in to comment.