Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- lib/metajp/templates/models/user.rb
Instance Method Summary collapse
-
#activate!(params) ⇒ Object
the second will take care of setting any data that you want to happen at activation.
- #deliver_activation_confirmation! ⇒ Object
- #deliver_activation_instructions! ⇒ Object
-
#deliver_password_reset_instructions! ⇒ Object
—————————————————————- password reset —————————————————————-.
-
#generate_temporary_password! ⇒ Object
—————————————————————- account general —————————————————————-.
-
#signup!(params) ⇒ Object
now let’s define a couple of methods in the user model.
Instance Method Details
#activate!(params) ⇒ Object
the second will take care of setting any data that you want to happen at activation. at the very least this will be setting active to true and setting a pass, openid, or both.
32 33 34 35 36 37 |
# File 'lib/metajp/templates/models/user.rb', line 32 def activate!(params) self.active = true self.password = params[:user][:password] self.password_confirmation = params[:user][:password_confirmation] save end |
#deliver_activation_confirmation! ⇒ Object
44 45 46 47 |
# File 'lib/metajp/templates/models/user.rb', line 44 def deliver_activation_confirmation! reset_perishable_token! Notifier.deliver_activation_confirmation(self) end |
#deliver_activation_instructions! ⇒ Object
39 40 41 42 |
# File 'lib/metajp/templates/models/user.rb', line 39 def deliver_activation_instructions! reset_perishable_token! Notifier.deliver_activation_instructions(self) end |
#deliver_password_reset_instructions! ⇒ Object
password reset
53 54 55 56 |
# File 'lib/metajp/templates/models/user.rb', line 53 def deliver_password_reset_instructions! reset_perishable_token! Notifier.deliver_password_reset_instructions(self) end |
#generate_temporary_password! ⇒ Object
account general
8 9 10 11 12 13 |
# File 'lib/metajp/templates/models/user.rb', line 8 def generate_temporary_password! chars = ("a".."z").to_a + ("1".."9").to_a temp_pass = Array.new(8, '').collect{chars[rand(chars.size)]}.join self.password = temp_pass self.password_confirmation = temp_pass end |
#signup!(params) ⇒ Object
now let’s define a couple of methods in the user model. The first will take care of setting any data that you want to happen at signup (aka before activation)
22 23 24 25 26 27 |
# File 'lib/metajp/templates/models/user.rb', line 22 def signup!(params) self.login = params[:user][:login] self.email = params[:user][:email] generate_temporary_password! save_without_session_maintenance end |