Sha256: b8f414687903e3c3fdb3976e479538776e20b3847b21ca41099bcdcb4fcb8140

Contents?: true

Size: 873 Bytes

Versions: 4

Compression:

Stored size: 873 Bytes

Contents

class Role < ActiveRecord::Base
  include MasterModel
  validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\z/ }
  has_many :user_has_roles
  has_many :users, through: :user_has_roles

  extend FriendlyId
  friendly_id :name
  translates :display_name

  def self.default_role
    Role.find_by(name: 'Guest')
  end

  private
  def valid_name?
    true
  end
end

# == Schema Information
#
# Table name: roles
#
#  id                        :integer          not null, primary key
#  name                      :string           not null
#  display_name              :string
#  note                      :text
#  created_at                :datetime
#  updated_at                :datetime
#  score                     :integer          default(0), not null
#  position                  :integer
#  display_name_translations :jsonb            not null
#

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enju_seed-0.4.0.rc.1 app/models/role.rb
enju_seed-0.4.0.beta.3 app/models/role.rb
enju_seed-0.5.0.beta.1 app/models/role.rb
enju_seed-0.4.0.beta.2 app/models/role.rb