Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Monday, September 8, 2014

Common RVM commands


  • Installing RVM

$>​ curl -L https://get.rvm.io | bash -s stable
$> rvm autolibs packages
          If you dont have curl you can install it using
$> sudo apt-get update
$> sudo apt-get install curl

  • Install specific ruby version:

          Installing version 2.0.0
$> rvm install 2.0.0
          Installing version 1.9.2
$> rvm isntall 1.9.2

  • Use a specific ruby version

$> rvm use 2.0.0

  • Use a specific ruby version and make it the default

$> rvm use --default 1.9.2

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.

Wednesday, September 3, 2008

Installing Ruby and Rails on Ubuntu

Ruby is not installed on Ubuntu out of the box. To get Rails working you will need to install ruby and some other things first. Simply enter following line on shell prompt

sudo apt-get install ruby ruby1.8-dev irb rubygems build-essential libopenssl-ruby

This will install ruby and ruby gems on your machine. To install rails enter following on shell prompt

sudo gem install rails rake mongrel


this will install rails and mongrel, a rails web server, on your system. If you dont need mongrel you can remove mongrel from the above line.

Sunday, June 15, 2008

Sqlite3 with Rails

Sqlite3 is an easy to use DBMS available as a library. It is a self contained and server less SQL database engine. Because of its ease of use and small foot print it has become DBMS of choice for low traffic web applications.
Using Sqlite3 with rails is real easy. Grab the binaries from Sqlite3 download page. for windows you will require sqlite-3_5_9.zip and sqlitedll-3_5_9.zip. Unzip these files and add them to your PATH environment variable ( or u can simply put the unzipped files to your ruby/bin directory) and you are ready. All Sqlite3 functionality is accessible via sqlite3.exe which you just unzipped and added to path.
To use sqlite3 with rails install sqlite3-ruby gem using gem command. Finally you will need to specify sqlite3 as the connection in the database.yml file of your rails application. Given below is development section of a sample database.yml

development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000

Notice that there is no username or password fields as they are not required.
When you do rake db:migrate database file will be created if not already exists.

Note: as of rails 2.0 sqlite3 is the default database and you will need to -d command line option when creating a rails application using to change it or you will need to change database.yml manually.