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

How to Enable Translations in Solidus

How to Enable Translations in Solidus

I struggled with this for a few days as I didn't find any coherent answert to my question: "How can I translate my Solidus app?" I tried a few different things and in the end was able to find the (super easy) solution thanks to some kind soul that helped me in...

What You Should Consider Before Starting Your Website

What You Should Consider Before Starting Your Website

If you're thinking about creating your own website, there are a few things you should consider before you can start thinking about fun stuff like colors and fonts. And of course, the list that I'm going to give you is not final, but these are things that you usually...

Stop Doing these Mistakes with Your Website

Stop Doing these Mistakes with Your Website

Today, I wanna talk about things you should stop doing with your websites. I've done hundreds of websites and I've seen these behaviors, especially on clients that are smaller companies or even solopreneurs. Typically they don't have the time or budget to think about...

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 *