Skip to content

Commit

Permalink
add set_date_of_birth
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Jun 5, 2021
1 parent 5ecb587 commit 2073326
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Profile < ApplicationRecord
translates :full_name
strip_attributes only: :user_number

attr_accessor :birth_date

searchable do
text :user_number, :full_name, :full_name_transcription, :note
string :user_number
Expand Down Expand Up @@ -43,6 +45,14 @@ 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

# ユーザの誕生日を設定します。
# @return [Time]
def set_date_of_birth
self.date_of_birth = Time.zone.parse(birth_date) if birth_date
rescue ArgumentError
nil
end
end

# == Schema Information
Expand Down

0 comments on commit 2073326

Please sign in to comment.