Just did the Rails upgrade to 2.0.2. Lots of new stuff … which is great, but there is no concept of backwards compatibility! After the upgrade, my app was immediately hosed! Some key changes that were made to session management were part of my problems, since I am using the acts_as_authenticated plugin. In my app’s controller, the line "observer :user_observer", was no longer recognized as a valid line of code. Instead, this has been moved to the environments.rb file. To get past this problem, simply add this line of code to your Initializer.run function, and remove the offending line from your controller.
config.active_record.observers = :user_observer
The second major problem I hit looked like this:
!\ FAILSAFE /!\ Mon Jan 21 13:39:53 -0500 2008 Status: 500 Internal Server Error A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" } in config/environment.rb
An easy fix, since the error told you exactly what to do. I put this line of code into my environments.rb file, right above the last fix:
config.action_controller.session = { :session_key => "_session", :secret => "some secret phrase of at least 30 characters" }
The last error I hit, had to do with the "scaffolding" I had set up. I thought scaffolding was a brilliant thing, providing a safety net, for all those simple functions, that you don’t need to be unique per app. Basically, if you put scaffold
bject at the top of your controller, it generates code for things like "new", "update", "create", "list", and "edit". It was so easy popping this one line into the controller. But with Rails 2.0.2 you see this error:
undefined method `scaffold’ for Controller:Class
Scaffolding in Rails 2.0 is now generated with a script. ./script/generate scaffold ModelName field1:type field2:type field3:type
Why not let us keep the old way too? Again, backwards compatibility does not seem to be the priority with this "cutting edge" platform.
The other thing you need to do after the upgrade, in the environments.rb file, is change the definition of RAILS_GEM_VERSION like this:
RAILS_GEM_VERSION = ’2.0.2′ unless defined? RAILS_GEM_VERSION
After applying those adjustments, my app was back up and running.