Sha256: e53d2dee9b909c9d5a4fbc09e82836887bb0763264d68bf1abf2b5c8cdbdb9a0

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

module Thredded
  class Role < ActiveRecord::Base
    ROLES = ['superadmin', 'admin', 'moderator', 'member']

    belongs_to :messageboard
    belongs_to :user, class_name: Thredded.user_class

    validates_presence_of :level
    validates_inclusion_of :level, in: ROLES
    validates_presence_of :messageboard_id
    validates_presence_of :user_id

    attr_accessible :level, :messageboard_id, :user_id

    scope :for, lambda { |messageboard| where(messageboard_id: messageboard.id) }
    scope :as,  lambda { |role| where(level: role) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thredded-0.0.1 app/models/thredded/role.rb