clarion/app/models/user.rb
2014-10-10 19:23:38 +03:00

24 lines
574 B
Ruby

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
has_one :speaker_profile
has_many :lectures
has_many :workshops
has_many :events
accepts_nested_attributes_for :speaker_profile, update_only: true
default_scope { order id: :desc }
def name
speaker_profile.try(:name) || email
end
def toggle_admin!
update admin: !admin
end
end