Wednesday, August 22, 2012

Introduction to Ruby on Rails

This blogpost is kind of summary for most of the tutorials out there on internet. Once you've gone through them and if you would like to note important steps - just bookmark this post.

Ruby on Rails Setup

We need rvm, ruby, rails and creation of a gemset

#Install rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

#check versions
rvm -v

#Gives the list of available ruby versions
rvm list known

#Install ruby version 1.9.3
rvm install 1.9.3

#Check version of ruby
ruby -v

#Create a Gemset rails3tutorial2ndEd and use it as default
rvm use 1.9.3@rails3tutorial2ndEd --create --default


Now Install rails for this particular gemset and ruby version


sudo rvm use 1.9.3@rails3tutorial2ndEd do gem install rails

Now all required gems are installed.
Also install git along with this. So now we have Ruby, RVM, Rails, Git
Check GEMS with "gem list"


Now create a rails projects

#creates a rails app with all required foldersrails new first_app

#enter the directory of our app
cd first_app



Edit the Gemfile  specifying the exact versions of the gems required

source 'https://rubygems.org'

gem 'rails', '3.2.8'

group :development do
  gem 'sqlite3', '1.3.5'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'


#Install the gems specified
bundle install

#start the server
rails server

Open the webpage http://localhost:3000

0 comments:

Post a Comment