Sunday, December 30, 2012

Creating a Spree application


Spree is an open source e-commerce platform that is available as a ruby gem for Ruby on Rails framework. It is intended as a foundation over which developers can build their own e-commerce sites.

Prerequisites

To use Spree you will need to install following:
  1. ruby
  2. imagemagick
  3. nodejs
  4. libxml2
  5. libxml2-dev
  6. libssl-dev
  7. libxslt-dev
  8. postgresql
  9. postgresql-server-dev-9.1
If you are using Ubuntu, you can easily install all of these from repos using aptitude. Imagemagick is required for resizing uploaded images. PostgreSql is selected because it is common in the hosting platforms but if you are not concerned about it, you can simply replace it with sqlite or anything else that you like.

Steps

After installing the above listed softwares, install bundler, rails, rake and spree gem using following command:
gem install bundler rake rails spree
Now create a new rails application. The default database is Sqlite, so we need to specify that we want postgres:
rails new myspreeapp -d postgresql
Edit config/database.yml and add host: localhost to all configurations and also correct database name, username and password. Next, add spree to your app. To do this run following command from withing your applications root directory:
spree install
This will run a wizard which will ask your choices for running migrations, loading seed data and others and perform the required actions. When the wizard ends your spree application is ready and you can now run it on local host using:
rails s
Your basic spree applications is now available at http://0.0.0.0:3000. You will most probably want to customize this application according to your needs. Head over to spree customization guides for a detailed look at customizing spree.

No comments: