May 31, 2017
Ruby on Rails Tutorial No Comments

Solidus (Ruby on Rails Tutorial)

On this Ruby on Rails tutorial, we will talking about Solidus. If you are new with Ruby on Rails, you might want to read this: What is Ruby On Rails as the Leading Programming Language Framework

So..different Rails have different opinion when people discuss about using Ruby On Rails for backed for the e-commerce project. Some think wordpress is better than that. But think about the brands like Shopify, they are the giant companies that are using Rails as the platform and serving millions of customers without any problem. In this article we are going to discuss about using Ruby On Rails as the e-commerce platform. We are going to take the advantage of the solidus gem which is the fork of spree ecommerce. This gem ships with the tools we need to set up a production ready mountable ecommerce engine.

Install Solidus

Make sure you have Imagemagic installed in your system before installing Solidus. After that create a new rails project and put these gems into your Gemfile.


gem ‘solidus’

gem ‘solidus_auth_devise’



Run the bundler.

$ bundle install


You have installed the gems but now you need to run the generators to create the necessary migrations and configurations. Run the following commands one by one

$ bundle exec rails g spree:install

$ bundle exec rails g solidus:auth:install

$ bundle exec rake railties:install:migrations


When you run the first command to install solidus, it will prompt you to enter email and password. That is to protect the admin section of your app.

Now run the migrations, solidus must have created bunch of migration files for you.

$ rails db:migrate


Note that if you want to use postgresql for the development database locally too, you can do that the configurations you need to make is to specify the db username and password in database.yml file.

I think everything must be up and running now. Fire up your terminal and run the rails server. Then navigate to localhost:3000 .The admin section of your app exists at localhost:3000/admin .

Solidus run slow in development environment but it works fine in production so there is nothing to worry about.


Admin Interface:

Admin interface contains lot of things for managing your store. You can view the orders you get, set the payment options, see the users that are signed up for the app, manage your stocks and products, promotion options and more. You can also add more features on your own form it.


Customize Solidus:

We want to tweak the solidus gem little bit. First let’s change the default logo for our store. Copy your logo to the logo directory in app/assets/images/logo/pic.png .Next, you need to change the name of logo image in the config/initializers/spree.rb

Spree.config do |config|

 # Frontend:


 # Custom logo for the frontend

 # config.logo = “logo/solidus_logo.png”


 config.logo = “logo/pic.png”





Note that you will need to restart the server whenever you change something in initializers file.

Now let’s customize the front end of our application. We want to install bootstrap to our store. So in the Gemfile add the following line

gem ‘bootstrap-sass’, ‘~> 3.3.6’


Then run the bundler to fetch the gem. One thing is tricky here, Solidus has a different manifest files to add the import statements. In regular rails app we used to add import statements in assets/application.css.scss. But for this add the statements in assets/stylesheets/spree/fontend/all.css and assets/javascrpits/spree/frontend/all.js . If you don’t already have these files and folders, create it.

# In assets/javascripts/spree/frontend/all.js

//= require jquery

//= require jquery_ujs

//= require spree


# In the assets/stylesheets/spree/frontend/all.scss

@import “bootstrap-sprockets”;

@import “bootstrap”;



In order to customize a view you should copy the file into your host app. Using Deface is not recommended as it provides lots of headaches while debugging and degrades your shops performance. Solidus provides a generator to help with copying the right view into your host app.

Simply call the generator to copy all views into your host app.

$ rails g solidus:views:override


If you only want to copy certain views into your host app, you can provide the –only argument:

$  bundle exec rails g solidus:views:override –only products/show


The argument to –only can also be a substring of the name of the view from the app/views/spree folder:

$ bundle exec rails g solidus:views:override –only product


After generating the views you can choose how you want to display the products and you can add custom behaviour to your store.



In case you want to translate a string depending on the locale.Solidus provides the internationalization gem for this issue.

gem ‘solidus_i18n’, github: ‘solidusio-contrib/solidus_i18n’, branch: ‘master’


Run the bundler. Then run the installer for the gem.

$ bin/rails g solidus_i18n:install


You can also set the default locale within config/initializers/spree.rb .

Spree::Frontend::Config.configure do |config|


 config.locale = ‘en-GB’



Spree::Backend::Config.configure do |config|


 config.locale = ‘en-GB’



You can read more about using the gem here.



Solidus provides you with a bunch of add-ons or extensions that can be used to extend your store. Let’s see an example of using the extension. We want to integrate the payment gateway extension.

Enter the following line in the Gemfile.

gem “solidus_gateway”


Then run bundler and installer.

bundle install
rails g solidus_gateway:install


Finally, make sure to restart your app. Navigate to Settings > Payments > Payment Methods in the admin panel. You should see a number of payment methods and the assigned provider for each. Click on the payment method you wish to change the provider, and you should see a number of options under the provider dropdown.

You can find more extensions here.



Solidus can be very much extended. There are gems that can turn your store into the api. By this you can integrate your store with other apps too like android apps or client side javascript apps. You can check the solidus documentation page for the class references and tweak the behaviours. You can also add extensions to make your storefront more powerful. The only thing I guess you must me focused on in front end because you get most of the things for normal stores already shipped with the gem. Make sure whenever you add the features to the gem, you make the great test coverage. This gem has limitless possibilities with which you can customize your store greatly.