Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.
Steps for Installation
Open terminal and run following commands.
- Step 1
$ sudo apt-get install build-essential git-core curl
- Step 2
$ curl -L get.rvm.io | bash -s stable
- Step 3
$ echo ‘[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”‘ >> ~/.bashrc
- Step 4
- Step 5
$ . ~/.bashrc
- Step 6
Check requirements for Ruby
$ rvm requirements
- Step 7
Install requirements of Ruby by RVM
$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
- Step 8
Install Ruby with 1.9.3 version
$ rvm install 1.9.3
- Step 9
Check Rubygems version. Its installed with Ruby.
$ gem -v
- Step 9
Install Rails latest version
$ rvm gem install rails
- Step 10
Check version of Ruby, Rails and Rubygems
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
$ gem -v
$ rails -v
Installation is complete. Now try RoR Apps.
If you find any error between steps then share it as comments.
Thanks for using this post.
OpenStreetView (OSV) is a Ruby on Rails application.
Requirements for OSV
- MySQL (Database)
- Ruby 1.8-dev
- Rails 2.3.8
Installation steps for requirements :
Open the terminal and run the following command :
$ sudo apt-get install mysql-server mysql-client
Open terminal and then write the following command :
$ sudo apt-get install ruby1.8-dev
Download Rubygems : rubygems-1.3.7.zip
Now unzip that using following command in terminal :
$ cd Downloads (Move to location where you downloaded rubygems)
$ unzip rubygems-1.3.7.zip
Now move rubygems-1.3.7 to /usr/local/src
Open terminal and write
$ cd Downloads
$ mv rubygems-1.3.7 /usr/local/src
After that install rubygems. Open terminal and run
$ cd /usr/local/src/rubygems-1.3.7
$ ruby setup.rb
You can install rubygems by running following command in terminal:
$ sudo apt-get install rubygems
Run following command in terminal:
$ sudo gem install rails -v 2.3.8
Now check whether you have installed each and everything correctly or not.
Run following in treminal:
$ ruby -v
$ gem -v
$ rails -v
After fulfilling the requirements, its time to download OSV code.
Download the code from:
And then extract that somewhere you want.
Or you can do as below:
sudo apt-get install git-core;
git clone git://github.com/johnmckerrell/OpenStreetView.git
git clone https://github.com/johnmckerrell/OpenStreetView.git
sudo gedit config/database.yml
It will Open the database.yml in Geditor. This file contain the Information regarding the Database connection for OSV So Carefully do as:
a)Change user and password of MySQL and socket as follow
Now edit the other file as:
sudo gedit config/environment.rb
// Change server name from www.openstreetview.org to localhost in line
// number 7, in line number 4, make version for RAILS_GEM_VERSION as ‘2.3.8’
Now Change the Directory as Follow as:
a)git clone http://github.com/technoweenie/restful-authentication.git restful_authentication
b)sudo rake gems:install
You are Just two Steps away to Run OSV. Now change the Directory as Following and do as:
The script/server will Start the server , Now you Can run the OSV at localhost as:
Browse in browser(localhost:3000)
Creating the Blog Application
For creating this application you must install Ruby on Rails on your system and also install the database to add the backend for your applicaton.
Click here for installing Ruby on Rails and MySQL Database.
Follow the steps for creating your blog application in Ruby on Rails :
- Open a terminal, navigate to a folder where you have rights to create files, and type :
$ rails blog -d mysql
-d mysql option create database with MySQL connectivity.
- Now move to blog folder using :
$ cd blog
- Database Configuration
Open the database.yml file to edit the database settings.
For this enter following commands in terminal:
$ cd config/
$ gedit database.yml
Replace username and password with your MySQL Username and password.
Update these changes in all three sections : development, test and production.
After saving these changes, run this command in terminal:
$ cd ..
- Database Creation
Run the following command in terminal to create database :
$ rake db:create
- Starting up Web Server
Run this command in terminal to run default webpage in browser:
- Creating Controller
Run this command in terminal:
ruby script/generate controller home index
- Edit Home Page
Open app/views/home/index.html.erb file. Run these commands in terminal:
$ cd app/views/home/
$ gedit index.html.erb
Add following line and Save the file.(You can also delete the previous text)
<h1>Hello Rails !</h1>
- Remove index.html from public folder
$ cd Desktop/blog
$ rm pulic/index.html
- Setting the Application Home Page
Open routes.rb file.
$ gedit config/routes.rb
Find the line beginning with root :root and uncomment it.
Replace that line with this :
map:root :controller => ‘home’, :action => ‘index’
Now save that file and if you navigate to http://localhost:3000 in your browser, you’ll see the home/index view.
- Creating a Resource
In the case of the blog application, you can start by generating a scaffolded Post resource. To do this, enter this command in your terminal:
$ script/generate scaffold Post name:string title:string content:text
- Running a Migration
Use following command to create tables:
$ rake db:migrate
- Add a Link
Open index.html.erb file to add link to My Blog page.
$ cd app/views/home/index.html.erb
Add this line at last,
<%= link_to “My Blog”, posts_path %>
and save the file.
The link_to method is one of Rails’ built-in view helpers. It creates a hyperlink based on text to display and where to go – in this case, to the path for posts.
- Test Your Blog Application
Now open http://localhost:3000/ in browser.
By these steps your blog is created and if you find any error then feel free to ask and share it through comments.