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 http://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=http://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: http://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 (3)

  1. (Caution: Ruby application names are as prolific, esoteric and funny as Microsoft code names) The previous

  2. Yaroslav says:

    To install Ruby on Rails for IIS 7.5 under Windows 7 please try http://www.helicontech.com/zoo

  3. Dmitry Pavlov says:

    There is a way to run RoR on IIS 8 via HttpPlatformHandler – described by Scott Hanselman in his post "Announcing: Running Ruby on Rails on IIS8 (or anything else, really) with the new HttpPlatformHandler" http://www.hanselman.com/…/AnnouncingRunningRubyOnRailsOnIIS8OrAnythingElseReallyWithTheNewHttpPlatformHandler.aspx