Thursday 2 February 2012

Installing Ruby on Rails on Win 7

As a Windows user the easiest way to get Ruby running on your machine is by using Ruby Installer. This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important documentation, and more.
1. Simply go to Ruby Installer for Windows Download Page and select the MSI installer files. In this tutorials I assumed that you will select the latest version or Ruby which is Ruby 1.9.2. So you will need to download the Ruby 1.9.2-p0.
2. After downloading the installer file, run it and accept the terms then on the installation destination and optional tasks page, browse to the location you want your installed files to be located “I prefer to make a folder called Ruby on the same partition where Windows folder are”. and don’t forget to check the check boxes as in the figure below.
Ruby 1.9.2 Installer
3. We have to make sure that our Ruby installation was successful. So we go to our Command Prompt “Start > All Programs > Accessories > Command Prompt” and type the following:
ruby --version
then hit enter. If no errors appears and the Ruby version displayed correctly as shown in the next image. Then you have successfully installed the Ruby Language on your Windows 7 System.
Check Ruby Version

Installing Rails:

1. Now it’s time to install the Rails. Simply type in the following command in your command prompt to install Rails and all dependencies
gem install rails --include-dependencies
This will take a while depending on your internet connection. So you can set back and grab yourself a cup of coffee.
Installing Rails
2. If everything went okay you should be able to see something link the previous image. at that point you have done so good. next step is to install our Database server.
3. now we need to install the required gems for rails and that can be made by running the following command in your command prompt:
bundle install
and now you are ready for the next step.


Installing Database Server:

I’d prefer to use MySQL as a database engine for my Rails applications. However you can feel free to use SqlLite3 which is by default the database engine associated with Rails.
1. Download the MySQL Community Server 5.1.50 select the recommended MSI Installer Essentials.
2. After downloading and running the installer make sure to choose complete on the first screen.
MySQL Server Installer
be sure to check on all windows warning before proceed.
3. After completing the installation wizard you will find a check box to start configuring your server
MySQL Server Wizard Complete
click on finish and let’s start customizing your MySQL server.
4. Follow the following screen:
a. Detailed Configurations
Detailed Configuration
b. Developer Machine
Developer Machine
c. Multifunctional Database
Multifunctional Database
d. MySQL Datafiles
InnoDB tablespace settings
e. Decision Support (DSS)/OLAP
Decision Support (DSS)/OLAP
f. TCP/IP Networking Port Settings & Firewall Exception
Port and Firewall Exception
g. UTF-8 Language Support “because we might write down stuff in arabic or in any other language than english and western languages”
UTF-8 Language Support
h. Service Name
Service Name
j. Security Settings
Security Settings
Hit next then execute and wait till all check points are green and voila, your MySQL server is ready… Next step is to test your installation and check if your computer is ready for the rails or not.


Testing your development environment:

1. Open a new Command Prompt window and navigate to the folder you want your projects to be created. I’ve created a new folder named it “Ruby Apps” and placed it in the root of my D: partition.
c: Users Hashem>D:
D:>md "Ruby Apps"
D:>cd "Ruby Apps"
D:Ruby Apps>

2. Now we will create a test application with the name of “my_app” and to do so we type the following command in the command prompt window
rails new my_app
Now a folder will be created including the complete folder and file structure for your new application.
3. Now it’s time to run the server and test the application we just created. Ruby installation comes with a build in web server called WEBrick. To run the server navigate to the newly created application and run the following command:
D:Ruby Apps>cd my_app
D:Ruby Appsmy_app>rails server

The WEBrick will communicate to your localhost via port 3000. so now head up to your browser and open
http://localhost:3000
If everything went ok you should be now looking at the Ruby on Rails: Welcome aboard default page.
You’re riding Ruby on Rails!

Notes:

  • The server will be closed if you terminate the command prompt window at any time. so be sure to leave that window open during the whole process when developing an application.
  • To terminate the server manually press “Ctrl + C” or just hit the close button.

No comments:

Post a Comment