问题
When I try to log in with the default admin user, I get "invalid email or password." Is there a way to create a user with code and try to log in that way?
I can log in on my live website, but not locally. My development code matches exactly what is on production.
回答1:
You can run a rails console
on your development server, and create a new admin user in the console itself.
The following is a typical sequence of such commands (change them according to your setup):
user = AdminUser.new
user.email = "<your email>"
user.password = "<your password>"
user.save
That will create the required admin for you. :)
回答2:
another way is to place this file into db
directory and then run
rake db:seed
or in console
Rails.application.load_seed
there you can see how AdminUser
is created, as well
来源:https://stackoverflow.com/questions/20447006/cant-log-into-active-admin-any-way-to-create-an-admin-user