clarion/app/models/personal_profile.rb

28 lines
859 B
Ruby
Raw 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
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
2015-07-28 15:43:19 +03:00
accepts_nested_attributes_for :user
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
end