Close

Not a member yet? Register now and get started.

lock and key

Sign in to your account.

Account Login

Forgot your password?

Installing Ruby on Rails on Win7

02 Sep Posted by in Blogs, Ruby on Rails | 23 comments
Installing Ruby on Rails on Win7
 

In the last two articles, I talked about what is Ruby and what is Ruby on Rails. and what is the meaning of MVC architecture. So we kinda have a general idea of what we will be talking about in the following articles. From this Article we will not only talk but we will start to create our first Ruby on Rails Application. and to do so we have to know what tools we will be using. and what is the best for us.

IN this whole Course I’ll assume that most of you are working on windows 7 machines. Ruby can be used in any operating systems and I’ll talk shortly on how to install the development environment on your system. So let’s get started. What we will do in this Tutorial is:

  • Install Ruby: Ruby recommends to install Ruby 1.8.7 or Ruby 1.9.2.
  • Install Rails: The current Rails version is 3.0.0 which were released August 29th, 2010.
  • Install Database Server: For Database I’ll use MySQL Community Server 5.1.50.
  • Testing your development environment by running your first application.

As we already know by now that Rails is an Open Source Web Application Framework written in Ruby. So to install Rails we first need to install the language and it’s package manager.

Get Listed

Installing Ruby:

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.

Get Listed

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.

Get Listed

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.

You are done

Congratulations, Now you have created and tested your development environment. If you faced any problems please do not hesitate and post them in the comments and I’ll get back to you with the answer at once.

Next time we will get more into creating our first simple Rails application. so stay tuned and you might wanna subscribe to our weekly Rails newsletter. Till we meet again, Have fun & Happy riding…

Get Listed

  1. Luis Lavena09-02-10

    Hello, nice tutorial.

    I would avoid recommend run things ad ministrator unless you installed RubyInstaller as administrator.

    So if you didn’t install Ruby as administrator, no need to run the command prompt as one.

    Even if your account belongs to administrators group, the installer do not require elevation of privileges.

    • Hashem E.Zahran.09-02-10

      Hello Luis, Thanks for stepping by.. You are right i was just working on a remote PC with and Administrator account that’s why most of the CMD screens are with the Admin level…

      • Luis Lavena09-02-10

        Cool.

        Another missing point is that using MySQL 5.1 will not work with binary mysql 2.8.1 gem. Either you will need to compile it (using the DevKit) or copy the 5.0 libmysql.dll

        I know, a huge bummer, but at least you can compile it!

        Details for that in our tutorials page:

        http://github.com/oneclick/rubyinstaller/wiki/tutorials

        • Hashem E.Zahran.09-02-10

          Thanks Luis, I’m aware of this issue but that appeared only when installing older version of Ruby & Ruby Gems. Actually that was fixed in the new version of Ruby Installer & the new Rails… I faced that when installing 1.8.7 & 1.9.1 but not anymore with this new version. I had to make sure that everything is working fine on a new fresh installation of windows on my development machine and it was all about the bundle gem installer in this version…

          The good thing in this new version, when you create a new project using the “rails new” command, it tells you what is missing before it continue to create your app. also when you run “rails new -d mysql” it checks if it will work or something is missing as well. Which is pretty cool feature. as I spent days trying to figure out why it’s not connection to MySQL server…

          • Luis Lavena09-02-10

            Hmn, maybe you’re not following me. I’m talking about mysql 2.8.1 gem, which binary has been compiled for MySQL 5.0, not 5.1

            Most of the time it will fail to work since libmysql.dll differs, ending on a segmentation fault and crash.

        • Hashem E.Zahran.09-03-10

          Aha, Thanks for correcting me Luis, I think I miss understood your point. I’ve been with ruby from only 8 months now. Didn’t face much problems till now but Um sure your help in correcting and following my tutorials will be a great help for me… Thanks again having the RubyInstaller Developer following my humble blog is a great pleasure :)

  2. Tim Santeford10-31-10

    Hey thanks for the post. You have a typo in step 1, “-include–dependencies” should be “–include-dependencies”. Could you do a post on installing curl and curb on windows? Thanks!

    • Tim Santeford10-31-10

      Yikes your blog post filter stripped out the dashes. I ment to post “{dast}{dash}include{dash}dependencies”

  3. Sarah12-01-10

    Thanks for a great tutorial, it helped me alot

    SArah

  4. mithun12-23-10

    Hi
    i am getting trouble in creating database i am using postgresql

  5. mithun12-23-10

    Hi
    how to create database and table in ruby on rails and how to use

  6. Gwen06-20-11

    I am getting errors while installing. Error while generating documentation for activerecord-3.0.9 Message: Invalid argument -./</cdesc-<.ri and then while installing documentation for rails I get the error file 'lib' not found. Can you help?

  7. foxrafi07-08-11

    I have the same problem, please help?

  8. Hashem07-10-11

    Hello Kindly be informed that those are now an outdated installation instructions for older versions of Ruby & Rails.. Kindly visit http://railsinstaller.org/ or http://rubyinstaller.org/

  9. Toan Nguyen09-19-11

    Please help with ‘lib’ not found. I did try reinstall dozen time. T.T

  10. Web Design Atlanta10-05-11

    Thanks for give this information, but i am getting erroe with installation…

  11. Amit10-26-11

    Can i use sqllite database instead of Mysql, will it be compatible with ruby 1.9.2 version.

  12. Sultana12-10-11

    I can’t install bundle please tell me the instruction for that. I have window 7.

  13. Bharath Kumar12-25-11

    Excellent… Thank you so much…

    But I got some error while installing about “json”. I installed DevKit to fix it.

    Anyway Very nice Thank you so much.

  14. Agus @ Ruby on Rails01-26-12

    A very good example of a complex explanation being explained in a way that encourages people to take on the task of adventuring into Ruby. If anyone had issues with mysql gem wanting to be installed all the time. Even though it has been. Go to the bin directory under the mysql main directory and copy libmysql.dll to your ruby bin directory. This will solve the quirky problem

  15. rajesh01-27-12

    is there any one to help me. Im having problem in installing bundle install. It is showing that
    case 1:when installing directly as above stated.
    c:\windows\system32>bundle install
    could not locate Gemfile

    case2: when im running it after creating small my_app application.
    D:\Ruby Apps\my_app>bundle install
    Fetching source index for https://rubygems.org/
    Could not reach rubygems repository https://rubygems.org/
    Could not find gem ‘jquery-rails (>= 0) x86-mingw32′ in any of the gem sources l
    isted in your Gemfile.

Leave a Reply

  1. Si estás empezando en Ruby On Rails…. | Labaroteca.com06-07-11
  2. Si estás empezando con Ruby On Rails » Labaroteca.com06-21-11