Thursday, September 30, 2010

Moving rails app from 2.3.5 to 2.3.9

In my last post, at the end, I mentioned about migrating my rails app from version 2.3.5 to 2.3.9 for making it more closer to rails 3.0. I worked on the same and it went well. I localized rack-1.1.0 version as rails 2.3.9 has this dependency. Most of the steps that I followed were similar to my earlier post except the change in version number.

Listing the deprecation warnings that need to be fixed that I received during the migration :-

(1) DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please
use :key instead. (called from new at app_root/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:72)

Change :session_key to :key in environment.rb file :-

config.action_controller.session = {
:key => '_radar_session',
:secret => '271c2f352da72.....'
}


(2) DEPRECATION WARNING: config.load_paths is deprecated and removed in Rails 3, please use autoload_paths instead

Change in the environment.rb file :-

From config.load_paths to config.autoload_paths

(3) DEPRECATION WARNING: Date#last_month is deprecated and has been removed in Rails 3, please use Date#prev_month instead. (called from ./spec/models/my_model_name_spec.rb:10)

(4) DEPRECATION WARNING: Time#last_month is deprecated and has been removed in Rails 3, please use Time#prev_month instead. (called from ./spec/models/my_model_name_spec.rb:41)

Here are the actual changes in rails 2.3.9 :-
app_root\vendor\rails\activesupport\lib\active_support\core_ext\date\calculations.rb

(5) DEPRECATION WARNING: Rake tasks in vendor/plugins/xss_terminate/tasks are deprecated. Use lib/tasks instead. (called from app_root/vendor/rails/railties/lib/tasks/rails.rb:10)

Move the tasks folder inside the lib folder of the plugin directory and the deprecation warning should go away. But you may need to change some require file paths according to new placement of tasks folder.

(6) DEPRECATION WARNING: Object#returning has been deprecated in favor of Object#tap. (called from helper at app_root/vendor/gems/rspec-rails-1.3.0/lib/spec/rails/example/helper_example_group.rb:59)

I googled around for this deprecation warning and found some useful articles. Sharing one of those articles :-

Upgrading to Rails 3: Beware of the Object#tap pattern
http://feeds.simonecarletti.com/simonecarletti/en


I also tried with rspec-rails-1.3.2 gem, but it also threw same deprecation warning. So I just opened the corresponding class and extended the implementation as :-

From
@helper_object ||= returning HelperObject.new do |helper_object|

To
@helper_object ||= HelperObject.new.tap do |helper_object|

I made similar change for app_root\vendor\gems\rspec-rails-1.3.0\lib\spec\rails\mocks.rb :-

From
returning model_class.new do |model|

To
model_class.new.tap do |model|

Now, I am much closer to moving my app to Rails 3.0 version :-)

No comments:

Post a Comment