Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/user.rb
Overview
Schema Information
Table name: users
id :integer not null, primary key
login :string(255)
first_name :string(255)
last_name :string(255)
birthdate :date
email :string(255)
emergency_pass :string(255)
created_at :datetime
updated_at :datetime
Class Method Summary (collapse)
-
+ (Object) new_with_params(params)
creates a new user with the params received.
Instance Method Summary (collapse)
-
- (Object) personal_key
returns the active personal_key.
-
- (Object) to_param
set the login as key for URLs.
Class Method Details
+ (Object) new_with_params(params)
creates a new user with the params received
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/user.rb', line 53 def self.new_with_params params traits = params[:user] user = User.new(traits) user.login = traits[:login] date = traits[:birthdate] begin user.birthdate = Date.new(date[:year].to_s.to_i, date[:month].to_s.to_i, date[:day].to_s.to_i) rescue user.birthdate = nil end user end |
Instance Method Details
- (Object) personal_key
returns the active personal_key
43 44 45 |
# File 'app/models/user.rb', line 43 def personal_key PersonalKey.current.find_by_user_id(self.id) end |
- (Object) to_param
set the login as key for URLs
48 49 50 |
# File 'app/models/user.rb', line 48 def to_param login end |