How to access the Spree administration section during production?

I followed Spree's instructions for customization, and I started working in development mode. I deployed from Capistrano in rackspace to a production server, but the same default entry ("spree@example.com" / "spree123") does not work. I created the user in the web interface, but, of course, he would not have admin privileges.

There is nothing in the manual that takes this into account: how can I create an administrator user during the production process when there are initially no users? Maybe I turned around wrong? I am using a very standard deploy.rb, should there be some special code to configure?

+8
ruby-on-rails admin spree
source share
6 answers

You can run rake spree_auth:admin:create if you use spree_auth_devise

+19
source share

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

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

During production, you start the console like this:

 RAILS_ENV=production rails c 
+13
source share

If you are deploying using heroku, be sure to follow these steps:

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

Seed will ask you to create a username and password for your administrator account.

Hope this helped.

+2
source share

If the user you created was the first user, he would actually have administrator rights.

+1
source share

Well,

I would advise you to manually create a user from the console, SSH to the server, export RAILS_ENV = production, rails c, and then find the user you want if it exists, then update the password manually or simply create a new user. What do you want, and depending on your version of Spree, you simply manually insert the entry into the replacement_ role, where role_id is 1 and user_id is the identifier of the user you just created.

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

You can also simply register for an account on your own site, then go to the console, find this user and add a role. There really is a million and one way to do this.

0
source share

You can use the following command

 rails spree_auth:admin:create RAILS_ENV=production 
0
source share

All Articles