Create Roles for Users with Devise

0

I have an application in Ruby on Rails, I use the gem devise to authenticate my users but I have to assign roles to those users (Main Adm., Article Manager and User). I would like to have routes and views for each user. They could tell me how I could do it. Thanks

    
asked by Leonardo Arellano 19.11.2017 в 05:39
source

1 answer

0

Hello anhade in your migration

t.integer     :rol

Go to the User model and add the following

enum rol: [:"Admnistrado Principal", :"Administrador de Articulos", :"Usuario"]

Then you define a private method to set a default role

private
  def user_default
    self.rol = :"Agente Comercial"
  end
end

Do not forget to call him before the registration for that you use

before_create :user_default

And I think with that it would be all about the roles.

    
answered by 20.11.2017 / 01:19
source