How to Add an Admin User in Solidus

I don’t know if this is the best or fastest way of doing this but in case you’re looking for an easy way to create a new user in Solidus with admin roles, here is a way that has worked for me.

Create a regular user

First go into your terminal and create a new user like this:

natalia = Spree::User.new(email:"youremail@example.com")

Solidus uses Devise gem for user management. If you’ve used this before you know that there is a model “User” which you can use. Solidus kind of wrappes this inside of their own class “Spree” (namespace), which is why you have to use it as described.

Assign the admin role

Now you can assign the admin role as follows:

natalia.spree_roles << Spree::Role.find_by(name: "admin")

The new user “natalia” has spree_roles (is an array). In order to assign the right role you can search for by looking for the name “admin”.

Now you are able to login via the Solidus admin panel

Solidus admin panel

Hi, I’m Natalia!

I create high-converting WordPress and WooCommerce websites that span many different fields with SEO woven into every aspect of the website design and development process.

Latest Posts

2 Comments

  1. vacation

    I’m really enjοying the tһeme/design of your weblog.
    Do ʏou ever run intߋ any internet browser ⅽompatibility problems?
    A handful of my blog aսdience have complained about
    my website not working correctly in Eⲭplorer but lookѕ great in Opera.
    Do you haѵe аny solutions to help fix this issue?

    Reply
    • Natalia

      Thank you for your comment! Yes, sometimes I face browser compatiblity issues too (mostly on Safari though). You can’t fix all issues (especially if clients haven’t updated their browsers in ages) but if you have specific issues try to figure out what the problem is using the Firefox/Chrome developer tools and then Google, Google, Google 😀 Let me know if there is a specific issue I can help you with!

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *