Running Rails 3.2.x under IIS 7.5, using SQL Server, and keeping the Asset Pipeline.

Posted on

So recently, I found myself having to run rails 3.2.11 (you did upgrade, right ?) unders Windows server 2008 r2 with SQL Server (probably latest version — I’ll ping that later) on IIS 7.5 with no proxy server (apache, nginx, thin, etc). I decided, that if I was going to have to go that far, lets make sure that we can still use the asset pipeline.

This tutorial uses ruby version 1.9.3p194 64 bit.

This tip works as of January 18, 2013.

This tutorial does not use the jruby approach (although, that is perfectly valid)
For jRuby, check out this stack overflow post; it looks accurate:

However, back to the subject at hand. The real secret here is this: use the windows ruby installer ( ( Luis and anyone working with him is doing a fantastic job) or the rails installer (, but not both. If you use the rails installer, you are going to have some extra configuration ( which might be worth it if you want RVM, git and ssh).

Step 0 (saves time later):
Make sure your Gemfile has these gems:

gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'

Make sure you have These fields defined in your database.yml

  adapter: sqlserver
  username: USERNAME_HERE
  password: PASSWORD_HERE

obviously, make sure you replace all those upcase phrases with your actual values.

Step one:
install Heliotech’s Zoo app:

As much as it pains me to say this, I didn’t use capistrano, however. They do have a deploy.rb file autogenerated in a “rails application” option.
As much as I wanted to use capistrano, this server was a temporary solution, so I have no reason to believe that the capistrano file would not have worked, but I did not get to actually test it.

Another repository that may be of interest is:
Your milage may vary.

Even though the deployment in question is temporary, it is still being used in production today with decent results. I’ll have to see if I can get some actual statistics. You will have to run all the normal rake tasks like

bundle exec rake assets:precompile

However, I do feel that Zoo is useful for actual production use.
If you have your choice, stick with nginx + unicorn, or apache + passenger, etc.

The single biggest annoyance is to make sure that your web.config file (an IIS thing) is correct.

Here is a gist ( )of a known working web.config IIS file. I have stripped out our real world (website identifying) data from it. If you see UPPERCASE_VALUES replace them with what makes sense. The web.config file belongs outside of the public directory in the rails root.

I’ve left in the option to run this either in 64 bit or 32 bit mode.
It is using FCGI through Rack at the end of the day.

The main difference between the gist web.config file and the default one is that we ensured that all the HTTP verbs that rails needs, it has available. We had an issue with devise’s JSON api.

Turned out that I was just an idiot and had incorrect code.
However, after some unit tests, I felt it was worth explicitly stating which verbs are allowed, because I’ve read about IIS being weird about POST before. I’m not an IIS expert and I am not sure if this is still a ongoing issue or not.

Leave a Reply

Your email address will not be published.