Showing posts with label e-commerce. Show all posts
Showing posts with label e-commerce. Show all posts

Tuesday, January 1, 2013

Deploying a Spree application on Heroku

Heroku is a no-hassle hosting solution for Ruby, Node.js, Clojure, Java, Python, and Scala. It helps the developers to focus on the most important thing i.e creating the most amazing web app ever and forget about servers. Your application can be up and running in minutes. All you need to do is create an app on their servers and then push your code to it using git. They provide a handy utility to create and manage applications from command line and it can be installed from www.toolbelt.heroku.com.

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.

Running a Spree application on Heroku is easy and can be done using the steps below.

Prerequisites

  1. A working spree application. If you want to know how to create one, read my previous post about creating a spree application.
  2. Working Heroku Account. If you don't already have one, sign up here.
  3. git client. On Ubuntu this can be easily installed using aptitude.

Steps

  1. Install Heroku Toolbelt.
    The toolbelt is a very handy utility for working with Heroku. The most important part of this toolbelt is a command line interface for creating and managing applications on Heroku server. For details and installation instructions please visit the Heroku Toolbelt website.
  2. Add your application to git version control.
    If not already done, add your app to git as this is required for pushing to Herokus servers. This is easily done using following commands:
    $ git init
    $ git add .
    $ git commit -m “initial commit”
  3. Next login to heroku from command line, add your SSH security keys to Heroku and create a new application
    $ heroku login
    $ heroku keys:add
    $ heroku apps:create myapp
  4. Push your changes to heroku
    $ git push heroku master
  5. Initialize your database
    $ heroku run bundle exec rake db:migrate
    $ heroku run bundle exec rake db:seed
And that is it. Your app should now be live at myapp.herokuapps.com. Head over to Heroku developer center for more details about this amazing platform or you can read this amazing book.

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.