Spree is the webshop solution for Ruby on Rails, and Heroku is the place to host your Rails-applications – especially if you like free hosting :)
Finding myself in the need of a webshop, I decided to try to deploy Spree to Heroku. It wasn’t too hard, but it did take a few tricks to get Spree running on a server that doesn’t allow you to write to the file system.
I can’t say I have too much hands-on experience with Spree yet, but it seems to be have borrowed its extension concept from Radiant CMS, which happens to be one of my areas of expertise. So I put together an extension for Spree that will easily allow you to deploy the e-commerce system to Heroku.
Just follow the instructions in the README on Github.
Hello, I'm Casper Fabricius. I have developed for the web for 9 years, and have been enjoying Ruby on Rails for the past 4.
My experience covers communities, shopping solutions, multi-language sites, heavy back-end lifting and a wide selection of more traditional websites. I like to integrate Ruby with Java and .NET through JRuby and IronRuby when it makes sense. I am passionate about test- and behavior-driven development, but at the same time I am pragmatic and believe in getting things done.
I am based in Copenhagen, Denmark, but I take assignments from across the globe. Feel free to study my resumé, featured projects and - of course - to hire me.
uberVU - social comments
October 18th, 2009 at 4:27 pm
Social comments and analytics for this post…
This post was mentioned on Twitter by fabricius: Hosting a Spree webshop on Heroku http://ff.im/-a3yTQ…
Magne K. Davidsen
November 5th, 2009 at 12:40 am
Hey Casper!
Thanks for a great blog post. I followed the steps in the instructions, and it works perfectly.
However, I would like to clone the spree source code, install the heroku extension, and deploy to Heroku.
When I try this, I get an error saying
“/usr/local/lib/ruby/1.8/fileutils.rb:1262:in `initialize’: Read-only file system”
I followed the exact same steps as for the spree gem. Do you have any ideas why this does not work?
Thanks a lot!
Casper Fabricius
November 5th, 2009 at 10:10 am
Hi Magne,
Glad you could use it. As for the error you get when cloning the Spree master repository, it could be for a number of reasons. Obviously the error is related to some code trying to write to disk, but as you haven’t included the stacktrace, I can’t see where it happens. Most likely it is Rails trying to cache some stylesheets or javascripts.
I have patched one specific error related to that I got with the 0.9.1 gem, but this can easily have changed in the “edge” version of Spree you get by cloning the repository. I will upgrade my extension to work with 0.9.2 when I have the time (perhaps it already does, you tell me?), but I can’t really play catch up with the edge version of Spree ;)
Cheers,
Casper
Magne K. Davidsen
November 5th, 2009 at 11:47 am
First of all, thanks for the quick answer!
Your extension already works with 0.9.2, so that is not the problem. I just changed the dependency :)
The stack trace can be seen here (at least for the time being):
http://spree-heroku-troublesome.heroku.com/
I must admit I don’t have to much experience with RoR, but I can’t really understand from this trace what part of the app that tries to do filewriting. The blank_iframe.html doesn’t really do anything.
Of course, it may be the caching of stylesheets you’re mentioning… Is there anyway to disable all caching in Rails?
Thanks again!
Casper Fabricius
November 9th, 2009 at 8:14 pm
Hi Magne,
Sorry to keep you waiting a bit longer this time. Nothing is clear from the stacktrace, since for the interesting part is just says ” … 34 levels…” ;)
However, I’d guess that it is trying the write the blank_iframe.html file – or perhaps delete it? Do you have some sort of extension that tries to generate this file perhaps?
/Casper
Nalin
February 16th, 2010 at 12:59 am
Hi Casper, great extension. Was wondering what’s the best way to turn off the extension in dev mode?
Thanks for your help!
Casper Fabricius
February 16th, 2010 at 10:18 am
Well, I’m pretty sure it works just like plugins: By default, all extensions are loaded alphabetically, and if you want it any other way you must specify the extensions you want to load in the config.
So, and I have not tested this, you could probably put something like this in your config/development.rb:
Hope this helps :)