Class: Spree::User

Inherits:
ActiveRecord::Base
  • Object
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

Returns:

  • (Boolean)


35
36
37
# File 'app/models/spree/user.rb', line 35

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.



30
31
32
33
# File 'app/models/spree/user.rb', line 30

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

Returns:

  • (Boolean)


39
40
41
# File 'app/models/spree/user.rb', line 39

def anonymous?
  email =~ /@example.net$/ ? true : false
end

#send_reset_password_instructionsObject



43
44
45
46
# File 'app/models/spree/user.rb', line 43

def send_reset_password_instructions
  generate_reset_password_token!
  UserMailer.reset_password_instructions(self).deliver
end