2015-05-30 18:24:12 +03:00
|
|
|
class PersonalProfile < ActiveRecord::Base
|
2014-08-07 14:05:13 +03:00
|
|
|
belongs_to :user
|
2015-05-30 18:53:14 +03:00
|
|
|
belongs_to :conference
|
2014-08-07 14:05:13 +03:00
|
|
|
|
|
|
|
validates :first_name, presence: true
|
|
|
|
validates :last_name, presence: true
|
2014-08-31 16:02:56 +03:00
|
|
|
validates :picture, presence: true
|
2014-08-07 14:45:58 +03:00
|
|
|
validates :mobile_phone, phony_plausible: true, presence: true
|
2014-08-07 14:05:13 +03:00
|
|
|
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
|
2014-08-07 14:45:58 +03:00
|
|
|
|
2015-05-30 18:24:33 +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
|
|
|
|
|
2014-08-07 15:19:28 +03:00
|
|
|
def twitter=(handle)
|
|
|
|
write_attribute :twitter, handle.gsub(/\A@/,'') if handle
|
|
|
|
end
|
2014-09-17 17:48:46 +03:00
|
|
|
|
|
|
|
def name
|
|
|
|
"#{first_name} #{last_name}"
|
|
|
|
end
|
2014-08-07 14:05:13 +03:00
|
|
|
end
|