Share via


Windows 7, IIS 7.5 and Ruby on Rails

Having spent the weekend working on Ruby on Rails with IIS/SQLServer 2008 Express backend via FastCGI, here are some tips to get you going:

  1. The best resource is Ruslan’s post on Rails and IIS7. In fact, go and bookmark this site right now. In Ruslan’s post, the web.config shown is best edited in a text editor.

  2. When installing IIS7.5 on Windows 7 Beta (build 7000) is easy: Using the Control Panels\Programs, Turn Windows Features On/Off. Underneath the Internet Information Services, you need to also install the CGI feature (to get FastCGI)

  3. Windows 7 and URL Rewrite: This forum post https://forums.iis.net/t/1154240.aspx will get you going whilst Windows 7 is in beta

  4. Database connectivity to SQLServer seems to be a common question. Installing the option “sqlserver adaptor” which is now an optional part of ActiveRecord:

     gem install activerecord-sqlserver-adapter --source=https://gems.rubyonrails.org
    

    Connecting via the ODBC adaptor via the SQL Native Client worked, rather than the ADO connector. My connector string looked something like this:

     development: 
      adapter: sqlserver 
      mode: odbc 
      dsn: Driver={SQL Native Client};Server=.\SQLEXPRESS;Database=xxxxx;
    
  5. As I am installing underneath the IIS7 root directory (that is: https://server/myapp) there are 3 small Rails tweaks required inform the application all the goodies are in a subdirectory:

    in config/environment.rb, the header, define a global variable:

     PATH_PREFIX = '/myapp'
    

    in config/environment.rb, in the Initializer, set the asset home directory:

     Rails::Initializer.run do |config|
        config.action_controller.asset_host = PATH_PREFIX
    

    in config/routes.rb, ActionController::Routing::Routes.draw:

       map.connect PATH_PREFIX + '/:controller/:action/:id'
      map.connect PATH_PREFIX + '/:controller/:action/:id.:format'
    end
    

Comments