Thursday, March 25, 2010

New Ruby on Rails Setup on Windows XP

Ruby on Rails(2.3.5) Setup on Windows XP

I followed the directions on rubyonrails.org

I installed rubyinstaller-1.8.7-p249-rc2.exe

Then I updated the gems.
-------------------------------------------------
update ruby gem
   C:\>gem update --system                 
install rails
   C:\>gem install rails                   
-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activeresource (2.3.5)                     
activesupport (2.3.5)                      
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
rubygems-update (1.3.6)                    
-------------------------------------------------

Install the mongrel gem
    C:\>gem install mongrel 
-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activeresource (2.3.5)                     
activesupport (2.3.5)                      
cgi_multipart_eof_fix (2.5.0)              
gem_plugin (0.2.3)                         
mongrel (1.1.5)                            
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
rubygems-update (1.3.6)                    
win32-service (0.5.2)                      


-------------------------------------------------

Install mongrel_service for mswin32
    C:\>gem install mongrel_service --platform=mswin32 
-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activeresource (2.3.5)                     
activesupport (2.3.5)                      
cgi_multipart_eof_fix (2.5.0)              
gem_plugin (0.2.3)                         
mongrel (1.1.5)                            
mongrel_service (0.3.4)                    
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
rubygems-update (1.3.6)                    
win32-service (0.5.2)                      
-------------------------------------------------
install gem for mySql
    C:\>gem install mysql 
-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activeresource (2.3.5)                     
activesupport (2.3.5)                      
cgi_multipart_eof_fix (2.5.0)              
gem_plugin (0.2.3)                         
mongrel (1.1.5)                            
mongrel_service (0.3.4)                    
mysql (2.8.1)                              
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
rubygems-update (1.3.6)                    
win32-service (0.5.2)                      
-------------------------------------------------
install sqlite gem
    C:\>gem install sqlite3-ruby 
-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activeresource (2.3.5)                     
activesupport (2.3.5)                      
cgi_multipart_eof_fix (2.5.0)              
gem_plugin (0.2.3)                         
mongrel (1.1.5)                            
mongrel_service (0.3.4)                    
mysql (2.8.1)                              
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
rubygems-update (1.3.6)                    
sqlite3-ruby (1.2.5)                       
win32-service (0.5.2)                      
-------------------------------------------------

It now works with slqite3 and mysql.

Lets add MS SQL server

install gem activerecord sqlserver adapter (http://github.com/rails-sqlserver/2000-2005-adapter)
    C:\> gem install activerecord-sqlserver-adapter 
I ran into a problem that it could install the gem so I have to dowdload devkit so it would "make" it has instruction on how to install.

installed devkit: unzipped rubyforge.org/frs/download.php/66888/devkit-3.4.5r3-20091110.7z 
into c:\ruby to get ruby-odbc to build
    C:\>gem install ruby-odbc  
        -- which built and installed v. 0.999



-------------------------------------------------
Let's see what's installed.

C:\>gem list --local                       
                                                                     
*** LOCAL GEMS ***                         
                                                                     
actionmailer (2.3.5)                       
actionpack (2.3.5)                         
activerecord (2.3.5)                       
activerecord-sqlserver-adapter (2.3.4)     
activeresource (2.3.5)                     
activesupport (2.3.5)                      
cgi_multipart_eof_fix (2.5.0)              
gem_plugin (0.2.3)                         
mongrel (1.1.5)                            
mongrel_service (0.3.4)                    
mysql (2.8.1)                              
rack (1.0.1)                               
rails (2.3.5)                              
rake (0.8.7)                               
ruby-odbc (0.9999)                         
rubygems-update (1.3.6)                    
sqlite3-ruby (1.2.5)                       
win32-service (0.5.2)                      
-------------------------------------------------

create a database on your SQL Server

Open your SQL Server client tool and create a database called sqlserverapp

Add a user with SQL Server authentication called user with secret as password to the database you just created.

Create an ODBC link name sqlserverapp to connect to this database.

Then you have to edit your database configuration file to tell rails to use SQL Server and your new database.

Create an ODBC link name sqlserverapp to connect to this database.

Edit the database.yml file.

Change the section under development with the following :

    development:
    adapter: sqlserver
    mode: odbc
    dsn: sqlserverapp 
    username: user
    password: secret
    host: mycomputer


Note : replace mycomputer with the name of your instance of SQL Server (in most cases, locahost should do the job).


You should be god to go.

Please see Rails 2 and SQL Server 2008 on Windows made simple for more information on connecting to the MS Sequel Server.

No comments: