Upgrading MeetingKoreans.com to Rails 1.2.6

Today I updated MeetingKoreans.com to Rails 1.2.6 using these instructions and it was quite a frustrating experience. There were three problems that took up most of the time.

  1. No route found to match “/photo/photo/nnn.png”

After upgrading to Rails 1.2.6 I immediately noticed that I was having problems accessing user photos from the database. I am embarrassed to say that this has been a problem on production since February 23, 2007 but until today I had not been able to reproduce this. Obviously the issue was that on production my web host had upgraded Rails but in my development environment I had not.

Previously I was creating the image tag for user photos like this.

  <%= image_tag url_for(:controller => 'photo', :action => 'photo',                        :id => user.primary_photo.id) %>

This would result in HTML like this.

  <img src="/photo/photo/1.png">

This was not a problem before but after the Rails upgrade I would see this error.

  [ERROR] application#index (ActionController::RoutingError)  "no route found to match "/photo/photo/1.png" with {:method=>:get}"

Therefore I changed the RHTML code like this.

  <img src="<%= url_for(:controller => 'photo', :action => 'photo',                        :id => user.primary_photo.id) %>"

This would result in HTML like this.

  <img src="/photo/photo/1">

Fortunately this solved the problem.

  1. undefined method ‘model’ for ApplicationController:Class

When I first did the upgrade I did not do the final step.

  rake rails:update:configs

This did not seem to be a problem at first when I ran it into the development mode. But when I ran it in production I saw errors like this, apparently because it was trying to run the application as a Rails 2.0 application.

  Status: 500 Internal Server Error

  undefined method 'model' for ApplicationController:Class

   /meetingkoreans.com/app/controllers/application.rb:13

Fortunately after running the rake update these errors no longer appeared.

  1. undefined method ‘model’ for ApplicationController:Class

After solving the above problem I immediately started seeing these errors.

  Status: 500 Internal Server Error

  Expected /meetingkoreans.com/app/controllers/mk_controller.rb to define MkController

    /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/

    dependencies.rb:249:in `load_missing_constant'

This one really puzzled me and as I searched around I learned that apparently many others were puzzled too. In this bug report, Expected x.rb to define X error, I found within the comments a work around from saizai that worked for me.

I suspect this setting in /config/environments/production.rb: config.action_controller.consider_all_requests_local = false

I changed this to ‘true’, restarted the server, and it worked. I then set it BACK to ‘false’, restarted… and it still worked.

So, I don’t really know for sure WHY it started working again or how this might be causing it, but hopefully it helps.

I have no idea why that worked but I am glad it did.

  1. Conclusion

I have been a web application programmer for over ten years and though I am still excited about Ruby on Rails I must admit this experience has lowered my opinion of it.  I have never seen upgrades to the platform cause applications to break so catastrophically like this and I have orchestrated migrations of major web applications before.  I shudder to think what the upgrade to Rails 2.0 will be like.

Leave a Reply

Your email address will not be published. Required fields are marked *