add roles to admin panel

This commit is contained in:
João Geonizeli
2022-07-21 10:45:48 -03:00
parent 734b6e911a
commit 705a465292
10 changed files with 209 additions and 100 deletions

18
app/models/role.rb Normal file
View File

@@ -0,0 +1,18 @@
# == Schema Information
#
# Table name: roles
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_roles_on_name (name) UNIQUE
#
class Role < ApplicationRecord
has_and_belongs_to_many :users
validates :name, presence: true, uniqueness: true
end

View File

@@ -26,5 +26,7 @@ class User < ApplicationRecord
:omniauthable,
omniauth_providers: [:google_oauth2]
has_and_belongs_to_many :roles
validates :name, presence: true
end