# frozen_string_literal: true # == Schema Information # # Table name: roles # # id :integer not null, primary key # name :string # resource_type :string # created_at :datetime # updated_at :datetime # resource_id :integer # # Indexes # # index_roles_on_name_and_resource_type_and_resource_id (name,resource_type,resource_id) # class Role < ApplicationRecord has_and_belongs_to_many :users, join_table: :users_roles belongs_to :resource, polymorphic: true, optional: true validates :resource_type, inclusion: { in: Rolify.resource_types }, allow_nil: true scopify resourcify end