This morning Derek and I were using the new respond_to and respond_with in a Rails 3 application. We noticed that when a user clicked on a link in Outlook a new Internet Explorer window would open with a prompt to download a file instead of rendering the page as we expected.
In our rails log we found that the request was being processed as:
Processing by FooController#index as
We would have expected to see:
Processing by FooController#index as HTML
At the top of our controller we saw that our respond_to was defined as:
respond_to :json, :html
We found that when the request type was missing, the first option was being used. In our case this was JSON. When we changed the respond_to call to list :html first the page was rendered as HTML like we expected.
Moral of the story, order matters.