Rails respond_to issues when using IE

I was experiencing a bug in IE7 where my Rails app would return js when I was asking for html and vice-versa.  It worked fine in other browsers but just not IE.  It seems a few other people were having this issue long ago but I could not find any recent info or a complete solution.  I quickly figured out that the order of my format statements in my respond_to block affected the result that I got from my reqeust.  So I could rearrange those and get the result I wanted.  But the problem was that I needed both at different times in my app.  That’s why you have them right?  Anyway, after reading over  a related post at info.michael-simons.eu I discovered that IE was sending the wrong accept-headers.  So I checked out the Prototype API and learned that I could set my accept-header for my ajax requests.  So I added  accept:'text/javascript' to my ajax options and it worked.  This was a real stickler for me so I wanted to document it here for others that were stuck on it.

Here is what my ajax request looked like:

new Ajax.Request(url, {
method: 'get',
parameters: params,
onCreate: function() {

Update: Looks like Paul Stadig might have a cleaner option. I haven’t tried it, but it looks like it might be the better way to go.

Passenger, Memory and mod_rewrite

Well, as I stated in my previous post, I enabled Passenger for my Austin Real Estate site.  Well, everything seemed fine for the first few days.  But then I noticed that my memory usage was steadily creeping up.  I killed my ruby processes and that helped but then it just started creeping up again.  After working with Dreamhost, they discovered there was a bug in that version of Passenger and they upgraded it for me and now my memory usage is much lower and holding steady.  However, I have another problem.  Apparently Passenger disables mod_rewrite.  This is fine since Passenger doeesn’t need it to run your Rails app.  However, I also had a wordpress instance on my domain.  I used a mod_rewrite to redirect users to the blog instead of Rails trying to interpret the url.  This no longer works and now my blog is dead.  I have several options to fix this.  After much deliberating, I have decided to move my Rails app to a subdomain, search.braxtonbeyer.com.  I will keep the blog on the main domain as it has most of the content. So, all in all, I am still satisfied with Passenger, but it does pay to do a little research before making major changes to your site.

Optimizing Rails Server Performance on Dreamhost

Lately, I have been working on some SEO for my Austin Real Estate site.  Slowly but surely my traffic has been increasing so I figured it was time for me to solve some long standing issues before my site gets too busy.  It is hosted on Dreamhost and has been pretty slow.  I built the site in Rails and it was my first production site built using Rails so I figured my ignorance with developing in Rails was causing the problem.  I did a lot of reading and optimized my code and environment as much as possible and it really didn’t seem to help much.

So I came to the conclusion that it was my host.  Dreamhost has been very open about how they feel about hosting Rails on a shared server.  DHH obviously disagrees.  But recently Dreamhost started offering a solution.  They now offer dedicated virtual hosting plans.  I decided to try it.  Mine was finally set up a couple of days ago.  Well my site immediately crashed.  Awesome.  My memory usage was constantly running too high.  I bumped up my memory allowance and the site became stable again and actually ran a bit faster.  However, I still wasn’t satisfied.  So then I tried setting up a Mongrel server which Dreamhost started offering along with the virtual servers.  I wasn’t too impressed.  So what was next?  Well Dreamhost also recently started offering Passenger as a Rails hostiing option.  I disabled the Mongrel and turned on Passenger.  The memory usage immediately dropped and the site had a noticeable speed increase.  I think I finally found my answer.  This was all a very unscientific series of tests by a complete novice sysadmin but I think the site is much better off.  Time will tell.