1 # == Schema Information
3 # Table name: user_roles
5 # id :integer not null, primary key
6 # user_id :bigint(8) not null
10 # granter_id :bigint(8) not null
14 # user_roles_id_role_unique (user_id,role) UNIQUE
18 # user_roles_granter_id_fkey (granter_id => users.id)
19 # user_roles_user_id_fkey (user_id => users.id)
22 class UserRole < ActiveRecord::Base
24 belongs_to :granter, :class_name => "User"
26 ALL_ROLES = %w[administrator moderator].freeze
28 validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }