The combination of Spree and Refinery is promising for e-commerce sites incorporating some CMS pages. I recently ran through the process of installing both of these engines and configuring them to play nice with each other. You can do this too!
Firstly, a note on versions. For this guide, I’ve use Rails 3.2.3, Spree 1.1rc and Refinery 2.0.2. I’ve used the Spree 1.1rc instead of the stable 1.0.x version because the stable version depends on Rails 3.1 and Refinery 2.0.x expects Rails 3.2. The Spree 1.1rc is Rails 3.2 compatible, so our whole project can happily run on Rails 3.2.
$ rails new spreefinery Uncomment therubyracer in the Gemfile
Install Spree 1.1rc
$ cd spreefinery $ spree install --git=git://github.com/spree/spree.git --branch=1-1-stable
Add to Gemfile: gem 'refinerycms', '~> 2.0.0' $ bundle install Comment out the Spree lines in db/seeds.rb to avoid double-seeding Spree $ rails generate refinery:cms --fresh-installation Uncomment the Spree lines in db/seeds.rb
Refinery uses the will_paginate gem for pagination, while Spree uses Kaminari. Unfortunately, these two gems are incompatible. To work around this, add the following to config/initializers/spreefinery.rb:
if defined?(WillPaginate) module WillPaginate module ActiveRecord module RelationMethods alias_method :per, :per_page alias_method :num_pages, :total_pages end end end end
I wanted my home page and an about page served by Refinery, and the products page served by Spree. To accomplish this:
Mount Spree before Refinery in config/routes.rb Above both engine mounts, add: root :to => "refinery/pages#home"
You should now have Spree and Refinery running together. There’s room for some further improvements to this configuration, since Spree and Refinery still use their own authentication systems and layouts, but it should be enough to get started with.
Become so much more better at emacs. Maybe not grammar, though.