Spree on Webfaction
A few months back on went on a search for the next best e-commerce framework. Of course only open source will do and while I really like the Cartridge plugin for Mezzanine to say Cartridge is in it’s infancy is an understatement. But other than Satchmo (who’s ship seems to have sailed) there aren’t really any good options from the django side. You’re pretty much left rolling your own.
I wanted something pretty complete out of the box. Which meant basic product and cart functionality, Stripe integration for payments and (the kicker) USPS shipping integration. After some looking I found Spree and starting going to town. It has a ton of things going for it. It’s in Rails so it was somewhat new to me but I dove in anyway. Spree has a great development team but I found the setup to be very tricky. I would follow their install guide exactly and it wouldn’t work because module A in the requirements needed to be a very behind or ahead. It took a long while but I finally got a development Spree environment working on my macbook pro.
This is supposed to be a how to post. Damn.
Cutting to the end, even after getting a full production install up and running on Webfaction I could never get the database to stabilize after installing the active shipping extension. After setting that up (not easy with the lack of documentation - or at least stuff a rails noob could follow) I always ended up with database errors after adding products.
After that very frustrating experience I can understand why PHP based carts that work more out of the box dominate the open source e-commerce space.
On to the setup!!!
First: Create a Rails 3.2.13(nginx 1.4.1/Passenger 4.0.2/Ruby 2.0.0) application via the control panel (I’m going to call mine spree, and assign it to a website record.
Created a PostgreSQL database and make a note of the database name and password.
SSH into the server and run the following commands exactly as shown (and in this order):
cd ~/webapps/spree
export PATH=$PWD/bin:$PATH
export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
gem install bundler
gem install pg -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
gem install spree_cmd
rails new YOURAPPNAME
cd YOURAPPNAME
export RAILS_ENV=production
Set the production database credentials in config/database.yml as follows:
adapter: postgresql
database: my_db_name
host: localhost
username: my_db_user
password: my_db_password
Edit Gemfile to make the following changes/additions: Update the 3rd line to
gem 'rails', '3.2.14'
Add the following:
gem 'jquery-rails',
gem 'pg'
gem 'therubyracer'
gem 'spree', '2.0.4'
Then run:
bundle update rails
cd to the YOURAPPNAME directory and run:
bundle install
spree install
Accepted the defaults after running “spree install”, then run:
rake assets:precompile
cd to spree folder and edit nginx/conf/nginx.conf Change the second to last line that says root /home/ACCOUNTNAME/webapps/spree/hello_world/public; and change hello_world to spree Restart nginx to load the new config.
~/webapps/spree/bin/restart
Fire up a browser and go view your awesome craftsmanship.
comments powered by Disqus