Sunday, August 1, 2010

Setting up Ruby on Rails Environment in Windows

Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. It is intended to be used with an Agile development methodology that is used by web developers for rapid development.
The following things are required in order to set up the ROR environment.
1Ruby Installation
2Testing the Ruby environment
3Rails Installation
4Setting up the server
5Setting up the database
6Testing the ROR environment
Ruby Installation

Rails framework is created using Ruby language and hence setting up the Ruby environment is the first thing to proceed. Download the latest ruby file ruby186-26.exe for windows and install it.
Testing the Ruby environment
Before moving on to rails, we need to test whether our ruby environment is set up properly or not. There are many tutorials available for testing it and you can check this blog Execute RUBY program on Command Prompt which is very simple to check at this stage.
Rails Installation
Once the ruby enviroment is ready, it is the time to install rails.Type the following in command prompt

gem update --system [To update the system with latest gems for ruby]
Ex: C:\ruby\prg>gem update --system
gem install rails --include-dependencies [Installation of rails along with all dependencies]
Ex: C:\ruby\prg>gem install rails --include-dependencies
The above installation is completed by automatically downloading from ruby site.
Setting up the server
Once the application is installed, we need to check whether the server setup is completed.By default, WEBrick server is coming along with rails installation. There is no seperate installation required.
In order to check the server, a sample application is required.
Type the following in command prompt
rails MyRails [creating an application called MyRails]
Ex: c:\rails>rails MyRails
Ex: c:\rails>ruby script/server [start the server & You will get a message console as given below....]
=> Booting WEBrick
=> Rails 2.3.8 application starting on
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-07-24 00:12:41] INFO WEBrick 1.3.1
[2010-07-24 00:12:41] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32]
[2010-07-24 00:12:41] INFO WEBrick::HTTPServer#start: pid=14200 port=3000
Now you can launch the application, http://localhost:3000 and a default welcome page will be displayed.
If you have done the above process, then server setup is completed.
Setting up the database
Rails can be easily configured with SqlLite database.We can install the database by remote using the below command.
install -r sqlite3-ruby
Ex: c:\rails>install -r sqlite3-ruby [remote installation of sqlite3 database]
In order to run the database, dll file is required and you can download here sqlit3 DLL Download
Download and extract the file[sqlite3.dll, sqlite3.def] in C:\WINNT\system32 folder.

Now your system is ready for working with database.
There are some firefox Add-Ons available in order to view the SQLite database.
Testing the ROR environment

You can test the above environment by writing sample applications.One of the simple tutorial to get started with is given in the blog, Ruby On Rails for Beginners
Now the ROR environment is ready you can successfully run any type of applications in Rails.
1Rails Forum
2Derek Anderson's blog
3Ruby Forum
4Execute Ruby Program on Command Prompt
5SqLite Downloads
6Ruby on Rails for Beginners

1 comment:

  1. Hello,

    Why did you install old One-Click Installer instead of RubyInstaller?

    Newer versions of RubyInstaller do perform faster than one-click and works better.

    Also, you recommend putting SQLite3 DLLs into system32, that is bad practice.

    I would suggest you look at RubyInstaller tutorials:

    For more up-to-date instructions.