Class: Profile
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Profile
- Defined in:
- app/models/profile.rb
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
Returns the value of attribute birth_date.
Instance Method Summary collapse
-
#set_date_of_birth ⇒ Time
ユーザの誕生日を設定します。.
-
#set_expired_at ⇒ Time
ユーザの有効期限を設定します。.
-
#set_role_and_agent ⇒ void
既定のユーザ権限を設定します。.
Instance Attribute Details
#birth_date ⇒ Object
Returns the value of attribute birth_date.
21 22 23 |
# File 'app/models/profile.rb', line 21 def birth_date @birth_date end |
Instance Method Details
#set_date_of_birth ⇒ Time
ユーザの誕生日を設定します。
69 70 71 72 73 |
# File 'app/models/profile.rb', line 69 def set_date_of_birth self.date_of_birth = Time.zone.parse(birth_date) if birth_date rescue ArgumentError nil end |
#set_expired_at ⇒ Time
ユーザの有効期限を設定します。
59 60 61 62 63 64 65 |
# File 'app/models/profile.rb', line 59 def set_expired_at if expired_at.blank? if user_group.valid_period_for_new_user > 0 self.expired_at = user_group.valid_period_for_new_user.days.from_now.end_of_day end end end |
#set_role_and_agent ⇒ void
This method returns an undefined value.
既定のユーザ権限を設定します。
52 53 54 55 |
# File 'app/models/profile.rb', line 52 def set_role_and_agent self.required_role = Role.find_by(name: 'Librarian') unless required_role self.locale = I18n.default_locale.to_s unless locale end |