The pros and cons of Ruby on Rails e-commerce in 2019

Photo by Jakob Owens on Unsplash
  • Create the Refinery site
  • Integrate Snipcart’s shopping cart
  • Make database migrations
  • Define new inventory
  • Build an e-commerce template

A few words on Ruby & Ruby on Rails

Ruby is a programming language. Rails is a server-side web framework written in Ruby. You can think of Rails as the Django to your Python or the Vue.js to your JavaScript. The framework always needs the language, but the language doesn’t always need the framework.

…Controversy: The “No True Scotsman” Argument against Rails

Why use Rails for e-commerce?

1. Clean, quick, and cost efficient

What are Some Great Rails E-commerce Tools?

Ok, so whether you love, tolerate, or choose to ignore Rails, everyone should at least have a look at the fully stocked Rails e-commerce solutions out there:

  • Solidus : An open-source e-commerce platform for high-volume businesses
  • Spree E-Commerce: Or, rather, Spree Commerce. A complete, scalable, and API-driven open source e-commerce framework
  • Ror-e: A complete e-commerce platform that claims to do it all from Purchase Order to Returns
  • Sharetribe: A peer-peer marketplace platform

Rails e-commerce tutorial with Refinery CMS

Installing what’s necessary

First things first, you’ll have to install what’s needed for Refinery to work. Now, I won’t go into much detail about how to do so because it’s thoroughly explained in their Installation Prerequisites.

Creating an extension

We could have overloaded the CMS pages to create our products, but we will be a little neater and create our own extension in order to keep Snipcart’s things apart. Refinery ships with an awesome extension scaffolding tool, and that’s what we’re going to use to generate ours. To do so, run the following command:

Migrating to Postgres

Now, SQLite3 is a great database to kickstart a project, but I think it can run short if you are building a full-blown production project. For that reason, we will migrate our database to Postgres instead of SQLite3. It will also make it easier for us to push to Heroku once we are ready for production. If you don’t already have Postgres installed you will have to download it here.

Creating views

At this point, we have a database with our products inside them. What we need to do is consume this data in order to show it in ‘views.’ Hit your server index which is typically http://localhost:3000. Then, hit the products link. Voilà! Your views should compile without errors now, and you should see all the corresponding product's information rendered as a list. The view is rather barebones so we will go ahead and make it a little funkier. Open your IDE again and hop to:

Deploying our store

Here’s the final step to get our store up and running for real clients. We will be using Heroku to host our [demo] but you’re not limited by that if you wish to go another route.

Live demo & GitHub repo

Closing thoughts

So that’s it! Overall, great experience with Rails and Refinery CMS.

  • It was fun to play with and it was a totally new experience.
  • RoR is a little bit tricker to work with on Windows, so I had to dive in some lower level configuration to make this work.
  • I found it fun and more challenging than simply adding a package to my project.
  • Ruby’s syntax was new to me and I felt completely lost for the first hour. Really simple things made me feel like I had gone astray.
  • There aren’t that many discussions about Refinery CMS online so if you can’t find your question in their docs, you will have to dig on your own.
  • Refinery CMS architecture felt a little bit convoluted. I really needed to dive deep into their docs to find what I thought were simple questions. Some principles I felt should have been a little bit more intuitive but, again, it was my first experience with Ruby so I am probably the one to blame ;)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store