Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create the first (Admin) user (CanCan and Devise)?

I made authentication in my Rails 3 app fallowed by Tony's tutorial

I don't want public registrations on my app, just to create new users with Admin account, but I can't create Admin account manually, because in table Users there is encrypted password and salt that must to be generated, and I don't know how :|

like image 885
dormitkon Avatar asked Mar 01 '11 02:03

dormitkon


1 Answers

You can do it from the rails console. From the command line goto the directory of your rails application and type rails console. Then enter the following code to create a user:

user=User.create!(:email=>'[email protected]',:username=>'test',:password=>'password') 

This will create a user object (assuming your devise resource is called User). Now you can use the user object that you just created to set admin privileges.

like image 190
Braden Becker Avatar answered Sep 30 '22 01:09

Braden Becker