Rails 2.0 deprecation warnings
Getting lots of deprecation warnings when running your Rails app (such as below)?
DEPRECATION WARNING: start_form_tag is deprecated and will be removed from Rails 2.0 (use form_tag instead) See http://www.rubyonrails.org/deprecation for details.
Want to check your Rails app for any deprecated code (that won’t work with Rails 2.0)?
The following rake task (from topfunky.net) will run through your source and notify of these outstanding problems so you can go through and tidy them up.
desc "Checks your app and gently warns you if you are using deprecated code."
task :deprecated => :environment do
deprecated = {
'@params' => 'Use params[] instead',
'@session' => 'Use session[] instead',
'@flash' => 'Use flash[] instead',
'@request' => 'Use request[] instead',
'@env' => 'Use env[] instead',
'find_all\b' => 'Use find(:all) instead',
'find_first\b' => 'Use find(:first) instead',
'render_partial' => 'Use render :partial instead',
'component' => 'Use of components are frowned upon',
'paginate' => 'The default paginator is slow. Writing your own may be faster',
'start_form_tag' => 'Use form_for instead',
'end_form_tag' => 'Use form_for instead',
':post => true' => 'Use :method => :post instead'
}
deprecated.each do |key, warning|
puts '--> ' + key
output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* -r '#{key}' *`
unless output =~ /^$/
puts " !! " + warning + " !!"
puts ' ' + '.' * (warning.length + 6)
puts output
else
puts " Clean! Cheers for you!"
end
puts
end
end
Simply create a .rake file in the lib/tasks directory and the new task will be available to use.
$ rake deprecated
Thanks Geoffrey Grosenbach!
About this entry
You’re currently reading “Rails 2.0 deprecation warnings,” an entry on Slash Dot Dash
- Published:
- 03.13.07 / 11pm
- Category:
- Ruby on Rails

Comments are closed
Comments are currently closed on this entry.