forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put user class extensions inside a to_prepare block
- Loading branch information
Showing
1 changed file
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|