Sha256: a4011bde0c1f071055ecc4adbcc95d030821f16ae434a9386e913fa6d668e826
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
class Profile < ApplicationRecord #################################################################### # User belongs_to :user, inverse_of: :profile # Role belongs_to :role, class_name: "Meta::Role", primary_key: :ref, foreign_key: :role, optional: true # Avatar has_one :avatar, class_name: "Asset", as: :assetable, dependent: :destroy accepts_nested_attributes_for :avatar, reject_if: :all_blank # Validation validates :name, length: { minimum: 2 }, allow_blank: true # => http://stackoverflow.com/a/22323406/1143732 # Nilify Blanks # Used for "name" validation -- submit nil if doesn't show nilify_blanks only: [:name] # Names alias_attribute :ref, :name # Slug extend FriendlyId friendly_id :name #################################################################### # Instance (private) ################### # => Name def name self[:name] || user.email end # => First Name def first_name name.split.first end # Class (public) ################### #################################################################### end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fl-0.3.9 | app/models/profile.rb |
fl-0.3.8 | app/models/profile.rb |
fl-0.3.6 | app/models/profile.rb |
fl-0.3.5 | app/models/profile.rb |