Class: Spree::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::User
show all
- Includes:
- Core::UserBanners
- Defined in:
- app/models/spree/user.rb
Defined Under Namespace
Classes: DestroyWithOrdersError
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.admin_created? ⇒ Boolean
41
42
43
|
# File 'app/models/spree/user.rb', line 41
def self.admin_created?
User.admin.count > 0
end
|
.anonymous! ⇒ Object
Creates an anonymous user. An anonymous user is basically an auto-generated User
account that is created for the customer behind the scenes and its completely transparently to the customer. All Orders
must have a User
so this is necessary when adding to the “cart” (which is really an order) and before the customer has a chance to provide an email or to register.
36
37
38
39
|
# File 'app/models/spree/user.rb', line 36
def self.anonymous!
token = User.generate_token(:persistence_token)
User.create(:email => "#{token}@example.net", :password => token, :password_confirmation => token, :persistence_token => token)
end
|
Instance Method Details
#anonymous? ⇒ Boolean
45
46
47
|
# File 'app/models/spree/user.rb', line 45
def anonymous?
email.nil? || email =~ /@example.net$/
end
|
#has_role?(role_in_question) ⇒ Boolean
has_role? simply needs to return true or false whether a user has a role or not.
29
30
31
|
# File 'app/models/spree/user.rb', line 29
def has_role?(role_in_question)
roles.any? { |role| role.name == role_in_question.to_s }
end
|
#last_incomplete_order ⇒ Object
54
55
56
|
# File 'app/models/spree/user.rb', line 54
def last_incomplete_order
orders.incomplete.order("created_at desc").last
end
|
#send_reset_password_instructions ⇒ Object