Sha256: e04484cd973019b5aeccf97abfea568c648c59130fdd9c738a34c667b77f7115

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

# In the parent application, users inhert from
# devise. These users have roles such as SuperAdmin,
# Admin, Coach etc in the parent application
class User < ActiveRecord::Base
  include ThinkFeelDoDashboard::Concerns::Password
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  has_many :coach_assignments, foreign_key: :coach_id, dependent: :destroy
  has_many :participants, through: :coach_assignments
  has_many :user_roles, dependent: :destroy
  has_many :groups, foreign_key: :moderator_id, dependent: :destroy
  validates :email, presence: true

  def admin?
    is_admin
  end

  def coach?
    user_roles.map(&:role_class_name).include?("Roles::Clinician")
  end

  def content_author?
    user_roles.map(&:role_class_name).include?("Roles::ContentAuthor")
  end

  def researcher?
    user_roles.map(&:role_class_name).include?("Roles::Researcher")
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.2.1 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.2.0.beta1 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.21 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.20 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.19 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.18 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.17 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.16 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.15 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.14 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.13 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.12 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.11 spec/dummy/app/models/user.rb
think_feel_do_dashboard-1.1.10 spec/dummy/app/models/user.rb