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.12.7 app/models/user_role.rb
think_feel_do_engine-3.12.6 app/models/user_role.rb
think_feel_do_engine-3.12.5 app/models/user_role.rb
think_feel_do_engine-3.12.4 app/models/user_role.rb
think_feel_do_engine-3.12.3 app/models/user_role.rb
think_feel_do_engine-3.12.2 app/models/user_role.rb
think_feel_do_engine-3.12.1 app/models/user_role.rb
think_feel_do_engine-3.12.0 app/models/user_role.rb
think_feel_do_engine-3.11.3 app/models/user_role.rb
think_feel_do_engine-3.11.0 app/models/user_role.rb
think_feel_do_engine-3.10.10 app/models/user_role.rb
think_feel_do_engine-3.10.9 app/models/user_role.rb
think_feel_do_engine-3.10.8 app/models/user_role.rb
think_feel_do_engine-3.10.7 app/models/user_role.rb
think_feel_do_engine-3.10.6 app/models/user_role.rb