added role to user

This commit is contained in:
Adrian Hinz 2019-12-12 11:35:40 +01:00
parent 43dcc338ad
commit e87f7fb731
5 changed files with 17 additions and 5 deletions

View File

@ -1,2 +1,8 @@
# frozen_string_literal: true
# Main ApplicationHelper
module ApplicationHelper module ApplicationHelper
def admin?
current_user.radmin?
end
end end

View File

@ -5,7 +5,7 @@ class User < ApplicationRecord
# == Constants ============================================================ # == Constants ============================================================
# == Attributes =========================================================== # == Attributes ===========================================================
enum role: %i[ruser radmin]
# == Extensions =========================================================== # == Extensions ===========================================================
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable, # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable,

View File

@ -36,9 +36,9 @@ Rails.application.configure do
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com', address: 'smtp.gmail.com',
port: 587, port: 587,
domain: 'akadeniatechnologii.pl', domain: 'akademiatechnologii.pl',
user_name: 'akadeniatechnologii@gmail.com', user_name: 'akademiatechnologii.pl@gmail.com',
password: '12345%$#@!Adi', password: '123456%$#@!Adi',
authentication: 'plain', authentication: 'plain',
enable_starttls_auto: true enable_starttls_auto: true
} }

View File

@ -0,0 +1,5 @@
class AddRoleToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :role, :integer, default: 0
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_05_02_114629) do ActiveRecord::Schema.define(version: 2019_12_10_124145) do
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
@ -129,6 +129,7 @@ ActiveRecord::Schema.define(version: 2019_05_02_114629) do
t.datetime "locked_at" t.datetime "locked_at"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "role", default: 0
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true