How to access the admin section of Spree in production?
Asked Answered
L

6

8

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?

Lukey answered 28/4, 2012 at 14:16 Comment(0)
L
19

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

Laager answered 2/3, 2013 at 0:38 Comment(0)
S
13

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
Sedge answered 7/11, 2012 at 21:36 Comment(0)
C
2

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.

Celebrate answered 10/9, 2015 at 11:24 Comment(0)
N
1

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

Nudi answered 30/4, 2012 at 21:5 Comment(0)
P
0

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.

Penninite answered 28/4, 2012 at 14:26 Comment(1)
I just ran rake db:bootstrap RAILS_ENV=production in my ssh command line, seemed to have gone through everything nicely.Lukey
S
0

You can use the following command

rails spree_auth:admin:create RAILS_ENV=production
Sparkie answered 14/10, 2019 at 2:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.