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:
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.
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)
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
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;
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
Anonymous
February 23, 2009
(Caution: Ruby application names are as prolific, esoteric and funny as Microsoft code names) The previousAnonymous
June 19, 2011
To install Ruby on Rails for IIS 7.5 under Windows 7 please try www.helicontech.com/zooAnonymous
February 08, 2015
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" www.hanselman.com/.../AnnouncingRunningRubyOnRailsOnIIS8OrAnythingElseReallyWithTheNewHttpPlatformHandler.aspx