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.19.9 app/models/user_role.rb
think_feel_do_engine-3.19.8 app/models/user_role.rb
think_feel_do_engine-3.19.7 app/models/user_role.rb
think_feel_do_engine-3.19.6 app/models/user_role.rb
think_feel_do_engine-3.19.5 app/models/user_role.rb
think_feel_do_engine-3.19.4 app/models/user_role.rb
think_feel_do_engine-3.19.3 app/models/user_role.rb
think_feel_do_engine-3.19.2 app/models/user_role.rb
think_feel_do_engine-3.19.1 app/models/user_role.rb
think_feel_do_engine-3.19.0 app/models/user_role.rb
think_feel_do_engine-3.18.0 app/models/user_role.rb
think_feel_do_engine-3.17.2 app/models/user_role.rb
think_feel_do_engine-3.17.1 app/models/user_role.rb
think_feel_do_engine-3.17.0 app/models/user_role.rb
think_feel_do_engine-3.16.3 app/models/user_role.rb
think_feel_do_engine-3.16.2 app/models/user_role.rb
think_feel_do_engine-3.16.1 app/models/user_role.rb
think_feel_do_engine-3.15.7 app/models/user_role.rb
think_feel_do_engine-3.16.0 app/models/user_role.rb
think_feel_do_engine-3.15.6 app/models/user_role.rb