Add role to users

This commit is contained in:
riggraz
2019-08-19 10:37:45 +02:00
parent fb924c9e75
commit b854562ca1
3 changed files with 14 additions and 1 deletions

View File

@@ -1,4 +1,11 @@
class User < ApplicationRecord
enum role: [:user, :moderator, :admin]
after_initialize :set_default_role, if: :new_record?
def set_default_role
self.role ||= :user
end
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,
:confirmable