clarion/app/models/personal_profile.rb

28 lines
860 B
Ruby
Raw Permalink Normal View History

class PersonalProfile < ActiveRecord::Base
belongs_to :user
belongs_to :conference
validates :first_name, presence: true
validates :last_name, presence: true
2014-08-31 16:02:56 +03:00
validates :picture, presence: true
validates :mobile_phone, phony_plausible: true, presence: true
validates :biography, presence: true
2014-08-07 15:19:28 +03:00
validates :public_email, format: {with: /\A[^@]+@[^@]+\z/}, allow_blank: true
validates :twitter, format: {with: /\A[a-z0-9_]{1,15}\z/i}, allow_blank: true
validates :github, format: {with: /\A[a-z0-9][a-z0-9\-]*\z/i}, allow_blank: true
2019-04-28 21:10:54 +03:00
phony_normalize :mobile_phone, default_country_code: "BG", add_plus: false
2014-08-07 15:19:28 +03:00
2014-08-31 16:02:56 +03:00
mount_uploader :picture, PictureUploader
2015-07-28 15:43:19 +03:00
accepts_nested_attributes_for :user
2014-08-07 15:19:28 +03:00
def twitter=(handle)
2019-04-28 21:10:54 +03:00
write_attribute :twitter, handle.gsub(/\A@/, "") if handle
2014-08-07 15:19:28 +03:00
end
2014-09-17 17:48:46 +03:00
def name
"#{first_name} #{last_name}"
end
end