Solidus is an open-source eCommerce solution built with Ruby on Rails and maintained by a community of passionate developers. In this blogpost we are going to set up a local development environment to start building an online store to sell pretty much whatever you want.
Let’s get started!
What do I need?
You can start your Solidus setup in almost any OS, in this case we will be using MacOS.
If you were to have a different Operating System, only adjust the commands to match your system requirements, keep in mind: : StackOverflow is your friend.
The Solidus official site has a pretty cool getting-started tutorial for setting up our development environment. In order to avoid reinventing the wheel, I will just add the instructions down below in the correct order. If you have any questions about why we need them, just take a look at the Solidus Guides site for a detailed explanation.
Now, let’s get our development environment up and running:
brew install ruby imagemagick
gem install rails
Great! Now we have everything we need to start building our own Solidus Store, so let’s do it!
Create a new Ruby on Rails application
Let’s create a new Ruby on Rails application. Solidus will run over this application in order to provide all the necessary stuff for a store to work properly. And here comes the most complex thing about software development: Naming things. Name your store as you want to, and make sure it looks gorgeous; mine will be ‘Amazing Store’, since I am going to sell amazing stuff.
rails new amazing_store
Now, assuming that you have previously worked with a Rails application, let’s go ahead and add the Solidus gems to the project via Gemfile:
gem 'solidus'
gem 'solidus_auth_devise'
And then install the gems:
bundle install
Finally let’s set up the solidus gems via the following commands:
bundle exec rails generate spree:install
bundle exec rails generate solidus:auth:install
bundle exec rails railties:install:migrations
bundle exec rails db:migrate
For a detailed explanation of every command you can always check the official documentation.
Setting up Postgres
Solidus comes with SQLite built-in as the database manager by default, though easy to use, SQLite is not intended to be a production grade database. We are going to use Postgres which will also facilitate our future deploy.
Let’s add the gem to the Gemfile:
gem 'pg'
And remove the SQLite gem.
Then let’s update the database.yml
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>;
timeout: 5000
development:
<<: *default
database: amazing_store_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: amazing_store_test
production:
<<: *default
database: amazing_store_production
Finally, we are ready to see our brand new store, let’s run:
rails s
Open the browser and navigate to: http://localhost:3000/
to take a look at your newly created store:
Congratulations! Your development environment setup is up and running! Following our next post, we will start customizing the look and feel of the store. In the meantime, navigate through your store, get yourself comfortable!
See you all in the next post! Stay tuned!