Rails 2.3.8 brings us a lot of warnings. Fixing them should help us migrate our applications to Rails3.0

Here are some of my depracation warnings and fixes:

DEPRECATION WARNING: ActionView::SafeBuffer is deprecated! Use ActiveSupport::SafeBuffer instead. (called from local_constants at /home/mencio/.gem/ruby/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/introspection.rb:74)

Warning generated by FCKeditor source code in file lib/fckeditor.rb:

include ActionView
module ActionView::Helpers::AssetTagHelper
  alias_method :rails_javascript_include_tag, :javascript_include_tag

  #  <%= javascript_include_tag :defaults, :fckeditor %>
  def javascript_include_tag(*sources)
    main_sources, application_source = [], []
    if sources.include?(:fckeditor)
      sources.delete(:fckeditor)
      sources.push('fckeditor/fckeditor')
    end
    unless sources.empty?
      main_sources = rails_javascript_include_tag(*sources).split("\n")
      application_source = main_sources.pop if main_sources.last.include?('application.js')
    end
    [main_sources.join("\n"), application_source].join("\n")
  end
end

Comment this stuff and include fckeditor on your own. Warning will not show again.

javascript_include_tag "fckeditor/fckeditor"

Another one:

DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. (called from new at /home/mencio/.gem/ruby/1.8/gems/actionpack-2.3.8/lib/action_controller/middleware_stack.rb:72)

Change in config/environment.rb :secret_ket into :key.:

  config.action_controller.session = {
    :secret_key => 'aaaaa' ,
    :secret => 'tajneprzezpoufne'
  }
  config.action_controller.session = {
    :key => 'aaaaa' ,
    :secret => 'tajneprzezpoufne'
  }

And the last one:

DEPRECATION WARNING: Omitting the leading slash

This one appeared only in test environment. Long, long time ago I've written some tests using assert_redirected_to but not corresponding to resources or controllers/actions but corresponding to pure URL parts (aka 'users/list'). You can fix it by:

  • using routes (smting_path)
  • adding slash before url route