Sha256: 59682e5fee474206de5c0a4d111dd3343f7b735522fe55b528d3531af728cf1c

Contents?: true

Size: 547 Bytes

Versions: 8

Compression:

Stored size: 547 Bytes

Contents

module Storytime
  class Role < ActiveRecord::Base
    has_many :users
    has_many :permissions
    has_many :allowed_actions, through: :permissions, source: :action

    validates :name, uniqueness: true

    def editor?
      name == "editor"
    end

    def writer?
      name == "writer"
    end

    def admin?
      name == "admin"
    end

    def label
      name.humanize
    end

    def self.seed
      find_or_create_by(name: "writer")
      find_or_create_by(name: "editor")
      find_or_create_by(name: "admin")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
storytime-2.1.6 app/models/storytime/role.rb
storytime-2.1.5 app/models/storytime/role.rb
storytime-2.1.4 app/models/storytime/role.rb
storytime-2.1.3 app/models/storytime/role.rb
storytime-2.1.2 app/models/storytime/role.rb
storytime-2.1.1 app/models/storytime/role.rb
storytime-2.1.0 app/models/storytime/role.rb
storytime-2.0.0 app/models/storytime/role.rb