E-Commerce in Rails with Spree

My current project is an e-commerce website for a high-end retailer. This project started out as being completely Greenfield – the requirements outlined a basic e-commerce website with some added features and a intra-day ETL process.

Since we had no wish to write an entire e-commerce platform from scratch we investigaged the different open source frameworks available to us. We knew that we would need to do some heavy customization of the framework and after some technical spikes we settled on Spree for the following reasons:

  • The underlying framework is Rails, which is a known entity – as opposed to something like Magento, which is PHP
  • The underlying framework is Rails, which means deployments and hosting can be done on something like Heroku
  • Spree allows us to easily customize the UI in a number of ways as well as modifying the business logic when needed – it’s designed to be customized
  • The documentation is very solid for an open source project

We have now been using Spree for around 2 months, so I think I have a good idea of how good the framework is.

The Good

Extending Spree’s user interface is really straightforward. Spree allows you to customize the user interface in 2 ways – either through Deface or by replacing entire view templates. We found that our changes tended to be more dramatic than what Deface would allow and therefore we replaced most of the view templates with our own.

Extending Spree’s logic is also very simple. Spree allows you to modify the logic in models and controllers in 3 different ways, but we only use one way – extending classes. You simply create a decorator file in the correct location and override the methods you want. I do find that I spend a large portion of my day viewing the Spree source code to figure out where I want to make changes, but I think this is to be expected as you’re using the framework more and more.

The Spree source code is very solid – I was especially impressed by the libraries used by Spree. You really get the impression that solid research went into every part of the application and I discovered a few cool libraries I hadn’t heard of before (Select2, AwesomeNestedSet, Ransack, etc).

The Documentation is pretty good – especially considering that this is an open-source framework. As I mentioned I do still spend a large amount of time looking at the source code to really understand what’s going on, but the documentation is a solid starting point and a definite plus.

The Bad

The models in Spree seem to really suffer from having too many lifecycle callbacks. This makes it difficult to test changes to the models and can sometime interfere when you’re adding libraries which add their own lifecycle hooks.

The Configuration seems to be partially contained in a configuration file and partially inside the database. While this is not a problem in itself (since an admin can make changes to some of the configuration), you have the ability to select the environment to which you are making the change. In my mind this makes absolutely no sense – why would you make a configuration change for the production environment while you are in the staging environment? Obviously this wouldn’t work – the only reason why I can imagine you would want this type of functionality is if you’re sharing a single database between multiple applications, which seems like a terrible idea.

Configuration Screenshot

The Search functionality in Spree is pretty good – the default searcher hits the database directly, but it allows you to plug in a more powerful search engine like Solr pretty easily. However, the search functionality in the admin interface uses a completely different searcher (Ransack) – which seems rather bizarre. The seems like an obvious form of duplication, one for which I don’t see a clear reason.


Overall I have been very happy with our choice of platform. Spree has given us very few issues while allowing us to roll out a completely customized e-commerce platform in two months. It has given us the ability to implement features at a very rapid rate while not getting in the way in day-to-day development.

I would highly recommend Spree as an e-commerce platform! Happy coding.