Sha256: bf0a3098691908911353980906c842bb6c3668d8f405eae748337cc411995047

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 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_translations :jsonb
#  note                      :text
#  created_at                :datetime         not null
#  updated_at                :datetime         not null
#  score                     :integer          default(0), not null
#  position                  :integer
#

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_seed-0.4.0.beta.1 app/models/role.rb
enju_seed-0.3.0.beta.4 app/models/role.rb
enju_seed-0.3.0.beta.3 app/models/role.rb