mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:39:52 +01:00
31 lines
767 B
Ruby
31 lines
767 B
Ruby
class Profile < ApplicationRecord
|
|
belongs_to :user
|
|
|
|
attr_readonly :user_id
|
|
|
|
validates :display_name, length: { maximum: 50 }
|
|
validates :location, length: { maximum: 72 }
|
|
validates :description, length: { maximum: 200 }
|
|
|
|
before_save do
|
|
unless website.blank?
|
|
self.website = if website.match %r{\Ahttps?://}
|
|
website
|
|
else
|
|
"http://#{website}"
|
|
end
|
|
end
|
|
end
|
|
|
|
def display_website
|
|
website.match(/https?:\/\/([A-Za-z.\-0-9]+)\/?(?:.*)/i)[1]
|
|
rescue NoMethodError
|
|
website
|
|
end
|
|
|
|
def safe_name
|
|
display_name.presence || user.screen_name
|
|
end
|
|
|
|
def question_length_limit = allow_long_questions ? nil : Question::SHORT_QUESTION_MAX_LENGTH
|
|
end
|