Sha256: ce9a4402c809f3ed8056b3ec19288668253adbb55007f146ac4e5ae3e90b116f

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

class FamilyGallery::User < ActiveRecord::Base
  devise :database_authenticatable, :recoverable, :rememberable, :trackable

  validates_presence_of :email
  validates_uniqueness_of :email

  has_many :owned_groups, class_name: "Group", foreign_key: "user_owner_id", dependent: :restrict_with_error
  has_many :owned_pictures, class_name: "Picture", foreign_key: "user_owner_id", dependent: :restrict_with_error
  has_many :pictures_tagged_on, through: :user_taggings, source: :picture
  has_many :user_roles, dependent: :destroy
  has_many :user_taggings, dependent: :destroy
  has_many :user_taggings_created, class_name: "UserTagging"
  has_many :uploaded_pictures, class_name: "Picture", foreign_key: "user_uploaded_id", dependent: :restrict_with_error

  scope :ordered, -> { order("family_gallery_users.first_name, family_gallery_users.last_name, family_gallery_users.email") }

  def name
    name = "#{first_name}" # Needs to be a new string.
    name << " #{last_name}" if last_name?

    name = email unless name.present?

    return name
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
family_gallery-0.0.8 app/models/family_gallery/user.rb
family_gallery-0.0.7 app/models/family_gallery/user.rb
family_gallery-0.0.6 app/models/family_gallery/user.rb
family_gallery-0.0.5 app/models/family_gallery/user.rb