Sha256: 9663791da8db420fb259881866188f31028d1cfde04d51c4bae68c5dff14c280

Contents?: true

Size: 414 Bytes

Versions: 55

Compression:

Stored size: 414 Bytes

Contents

# The assignment of a Role to a User.
class UserRole < ActiveRecord::Base
  ROLES = [
    "Roles::Clinician",
    "Roles::Researcher",
    "Roles::ContentAuthor"
  ]

  belongs_to :user

  validates :user, :role_class_name, presence: true
  validates :role_class_name, inclusion: { in: ROLES }
  validates :role_class_name, uniqueness: { scope: :user_id }

  def role
    role_class_name.constantize.new
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
think_feel_do_engine-3.15.5 app/models/user_role.rb
think_feel_do_engine-3.15.4 app/models/user_role.rb
think_feel_do_engine-3.15.3 app/models/user_role.rb
think_feel_do_engine-3.15.2 app/models/user_role.rb
think_feel_do_engine-3.15.1 app/models/user_role.rb
think_feel_do_engine-3.15.0 app/models/user_role.rb
think_feel_do_engine-3.14.9 app/models/user_role.rb
think_feel_do_engine-3.14.8 app/models/user_role.rb
think_feel_do_engine-3.14.7 app/models/user_role.rb
think_feel_do_engine-3.14.6 app/models/user_role.rb
think_feel_do_engine-3.14.5 app/models/user_role.rb
think_feel_do_engine-3.14.4 app/models/user_role.rb
think_feel_do_engine-3.14.3 app/models/user_role.rb
think_feel_do_engine-3.14.2 app/models/user_role.rb
think_feel_do_engine-3.14.1 app/models/user_role.rb
think_feel_do_engine-3.14.0 app/models/user_role.rb
think_feel_do_engine-3.13.1 app/models/user_role.rb
think_feel_do_engine-3.13.0 app/models/user_role.rb
think_feel_do_engine-3.12.9 app/models/user_role.rb
think_feel_do_engine-3.12.8 app/models/user_role.rb