class UserRole < ActiveRecord::Base
belongs_to :user
- ALL_ROLES = %w(administrator moderator)
+ ALL_ROLES = %w(administrator moderator).freeze
- validates_inclusion_of :role, :in => ALL_ROLES
- validates_uniqueness_of :role, :scope => :user_id
+ validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }
end