Devise: Add Admin Model

Created on 13 Oct 2016  路  3Comments  路  Source: heartcombo/devise

Hello,

Rails version: 5.0.0.1
Devise version: 4.2.0

I followed the first option to create an Admin role as recommended here https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-Role

After that, I created a seed to populate the Admin Model:

Admin.create!({email: "[email protected]"},
                  {password: "password"},
                  {password_confirmation: "password"})

Admin Model

class Admin < ApplicationRecord
 devise :database_authenticatable, :trackable, :timeoutable, :lockable 
end

Routes

Rails.application.routes.draw do
 devise_for :admins
end

I tried to sign_in with this password at /admins/sign_in without sucess.
At the rails console I can see the Admin.first, so i don't have idea what im doing wrong. Any idea?

Most helpful comment

@Pedroknoll I followed same steps but could not reproduce issue. Just one change I did is I created Admin using following as syntax you given is incorrect.

Admin.create(email: '[email protected]', password: '12345678', password_confirmation: '12345678')

All 3 comments

@Pedroknoll I followed same steps but could not reproduce issue. Just one change I did is I created Admin using following as syntax you given is incorrect.

Admin.create(email: '[email protected]', password: '12345678', password_confirmation: '12345678')

Please use the mailing list or StackOverflow for questions/help, where a wider community will be able to help you. We reserve the issues tracker for issues only.

Having problems accessing the Admin log in with devise as I can't remember the password and email. Any suggestions on how to fix this?

Was this page helpful?
0 / 5 - 0 ratings