打印

版主能不能说说rails从2.0.2升级到2.1后需要升级的东西?

版主能不能说说rails从2.0.2升级到2.1后需要升级的东西?

如比较常用gem plugin以及在程序中特别容易出错的地方?

TOP

原文地址:
http://www.slashdotdash.net/arti ... ils-2-upgrade-notes
大概翻译一下..
先编写个rake
lib/tasks/rails.rake

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'   => 'Use find(:all) instead',
    'find_first' => '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

然后检测
rake deprecated
没有错误你就可以升级了,有问题就需要修改了.
文章后边有一些升级需要的操作..自己看吧.

TOP

这篇文章不是说的从1.2.6升到2吗?

TOP