OpenstreetView (OSV) – RoR Application

OpenStreetView (OSV)  is a Ruby on Rails application.
Requirements for OSV
  1. MySQL (Database)
  2. Ruby 1.8-dev
  3. Rails 2.3.8
  4. Rubygems
Installation steps for requirements :
  1. MySQL

    Open the terminal and run the following command :
    $ sudo apt-get install mysql-server mysql-client

  2. Ruby 1.8-dev

    Open terminal and then write the following command :
    $ sudo apt-get install ruby1.8-dev

  3. Rubygems

    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

    OR

    You can install rubygems by running following command in terminal:
    $ sudo apt-get install rubygems

  4. Rails 2.3.8

    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:

https://github.com/johnmckerrell/OpenStreetView/downloads

And then extract that somewhere you want.

Or you can do as below:

mkdir OSV
cd OSV
sudo apt-get install git-core;
git clone git://github.com/johnmckerrell/OpenStreetView.git
// or
git clone https://github.com/johnmckerrell/OpenStreetView.git
cd OpenStreetView
cd config
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
b)socket: /var/run/mysqld/mysqld.sock

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:

cd vendor/plugins/
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:

a)cd OSV/OpenStreetView
b)rake
c)rake db:migrate
d)script/server

The script/server will Start the server , Now you Can run the OSV at localhost as:
 Browse in browser(localhost:3000)

Virtualbox

Virtualbox is a tool that provides to run multiple OS’s without rebooting your system. You can install any OS using virtualbox. Its a great tool to run another OS within another OS. For example, If you have installed Ubuntu 12.04 and you want to install Ubuntu 11.10. Then you have option that you can install that alongside Ubuntu 12.04. But with this step you have to reboot each time to switch between different OS’s.

But you can install Ubuntu 11.04 within Ubuntu 12.04 using Virtualbox.

Installation steps for Virtualbox:

  • Step 1
    wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add –
  • Step 2
    sudo sh -c ‘echo “deb http://download.virtualbox.org/virtualbox/debian precise contrib” >> /etc/apt/sources.list’
  • Step 3
    sudo apt-get update && sudo apt-get install virtualbox-4.1

Now open dashboard and type virtualbox,

then open that. It looks like below:

Trip to Rajgarh, HP (22-06-2012)

GD Trip : It was a great trip, enjoyed alot with all members. I was too excited for trip. I wake up at 3:00 am in morning and  get ready for trip. I also told my mom to make rice as order by Sandy. By 4: 30 AM we were started journey  to Rajgarh (Destination). Our first stop was Pinjor Garden, Here we clicked pics and also enjoyed Poha. It was very yummy. After spending some time there, we move on to Rajgarh. And then we reached there by 3:00 PM. That was the best time of trip. Here we could experience actual beauty of nature. We did tracking and capture that movements in camera. And then we all eat mangoes, sitting on rocks, enjoying weather. It was a nice experience and difficult to express. At Last we went to Badu Sahib, nice place. At last we headed towards Ludhiana. Around 3:00 AM we reached to college and most of the day-scholars spent night in hostel, I’m also one of them. Well this trip was adventurous and full of enjoyment.

Ruby on Rails – Blog Application (Rails 2 App)

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 :

    1. 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.

    2. Now move to blog folder using :

      $ cd blog

    3. 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 ..

    4. Database Creation

      Run the following command in terminal to create database :

      $ rake db:create

    5. Starting up Web Server

      Run this command in terminal to run default webpage in browser:

      $ script/server

    6. Creating Controller

      Run this command in terminal:

      ruby script/generate controller home index

    7. 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>

    8. Remove index.html from public folder

      $ cd
      $ cd Desktop/blog
      $ rm pulic/index.html

    9. 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.

    10. 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

    11. Running a Migration

      Use following command to create tables:

      $ rake db:migrate

    12. 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.

    13. Test Your Blog Application

      $ script/server

      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.

Configuring the Database in Ruby on Rails

Configuring a Database

Just about every Rails application will interact with a database. The database to use is specified in a configuration file, config/database.yml. If you open this file in a new Rails application, you’ll see a default database configured to use SQLite3. The file contains sections for three different environments in which Rails can run by default:

  • The development environment is used on your development/local computer as you interact manually with the application.
  • The test environment is used when running automated tests.
  • The production environment is used when you deploy your application for the world to use.

1) Configuring an SQLite3 Database

Rails comes with built-in support for SQLite3, which is a lightweight serverless database application. While a busy production environment may overload SQLite, it works well for development and testing. Rails defaults to using an SQLite database when creating a new project, but you can always change it later.

Here’s the section of the default configuration file (config/database.yml) with connection information for the development environment:

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

In this guide we are using an SQLite3 database for data storage, because it is a zero configuration database that just works. Rails also supports MySQL and PostgreSQL “out of the box”, and has plugins for many database systems. If you are using a database in a production environment Rails most likely has an adapter for it.

2) Configuring a MySQL Database

If you choose to use MySQL instead of the shipped SQLite3 database, yourconfig/database.yml will look a little different. Here’s the development section:

  development:
  adapter: mysql
  encoding: utf8
  database: new_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

If your development computer’s MySQL installation includes a root user with an empty password, this configuration should work for you. Otherwise, change the username and password in the development section as appropriate and you can also do these changes in test and production sections too.

3) Configuring a PostgreSQL Database

If you choose to use PostgreSQL, your config/database.yml will be customized to use PostgreSQL databases:

  development:
  adapter: postgresql
  encoding: unicode
  database: new_development
  pool: 5
  username: blog
  password:

You can also do these changes in test and production sections.

Change the username and password in the development section as appropriate.

Creating the Database

Now that you have your database configured, it’s time to have Rails create an empty database for you. You can do this by running a rake command:

$ rake db:create

This will create your development and test  databases inside the db/ folder