bluebit
bluebit

Reputation: 3017

How to access the admin section of Spree in production?

I have followed the Spree instructions for setting up, and I got it working in development mode. I deployed with Capistrano to rackspace to a production server, but the same default login ("[email protected]"/"spree123") does not work. I created a user in the web interface, but of course it would not have admin priveleges.

There is nothing in the guide that takes this into account - how can I create an admin user in production when there are no users at all initially? Maybe I deployed incorrectly? I am using a very standard deploy.rb, must there be some spree-specific code for setting this up?

Upvotes: 8

Views: 11101

Answers (6)

Asme Just
Asme Just

Reputation: 1337

You can use the following command

rails spree_auth:admin:create RAILS_ENV=production

Upvotes: 0

ashga
ashga

Reputation: 269

If the user you created was the first user it would in fact have admin rights.

Upvotes: 1

Martijn Kerckhaert
Martijn Kerckhaert

Reputation: 494

If you are deploying with heroku make sure to do following:

heroku run rake db:migrate
heroku run rake db:seed

The seed will ask you to create a username and password for your admin account.

Hope this helped.

Upvotes: 2

geermc4
geermc4

Reputation: 568

You can run rake spree_auth:admin:create if your using spree_auth_devise

Upvotes: 19

yorch
yorch

Reputation: 7318

You can add any user to the Spree Admin Role from the console rails c, doing the following:

user = user.find({your id})
user.spree_roles << Spree::Role.find_by_name(:admin)

In production, you would run the console this way:

RAILS_ENV=production rails c

Upvotes: 13

J. Martin
J. Martin

Reputation: 1737

Well,

I would suggest that you manually create the user from the console, SSH to the server, export RAILS_ENV=production, rails c, and then Find the User that you want, if they exist, and then update the password manually, or simply create the new user. That you want, and depending on your version of Spree, you just manually insert a record into roles_users where the role_id is 1 and the user_id is the id of the user you just created.

It may depend on the version you are using. But I'd just do it from the console, it's easier in my opinion.

You could also just sign up for an account on your own site, then go to the console, find that user, and add the role. There's really a million and one ways to do it.

Upvotes: 0

Related Questions