1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/models/role.rb

26 lines
514 B
Ruby
Raw Normal View History

2018-11-29 18:26:48 -05:00
# frozen_string_literal: true
class Role < ApplicationRecord
2019-02-01 16:01:02 -05:00
NAMES = %w[
superuser
].map(&:freeze).freeze
2018-12-05 20:22:39 -05:00
has_and_belongs_to_many :accounts, join_table: :account_roles
2018-11-29 18:26:48 -05:00
belongs_to :resource, polymorphic: true, optional: true
2019-02-01 16:01:02 -05:00
validates :name,
presence: true,
inclusion: { in: NAMES }
2018-12-05 20:48:13 -05:00
2018-11-29 18:26:48 -05:00
validates :resource_type,
allow_nil: true,
inclusion: { in: Rolify.resource_types }
scopify
def human_name
I18n.translate name, scope: :roles
end
2018-11-29 18:26:48 -05:00
end