Rails 3弃用了方法和API

Oma*_*Ali 15 ruby-on-rails upgrade deprecated ruby-on-rails-3

在哪里可以找到已弃用的方法,API等列表,以便从Rails 2.x升级到Rails 3?

Pau*_*ber 32

The Rails 3 release notes have lots of good information:

Railties now deprecates:

  • RAILS_ROOT in favor of Rails.root,
  • RAILS_ENV in favor of Rails.env, and
  • RAILS_DEFAULT_LOGGER in favor of Rails.logger.

ActionController:

  • The cookie_verifier_secret has been deprecated and now instead it is assigned through Rails.application.config.cookie_secret and moved into its own file: config/initializers/cookie_verification_secret.rb.
  • filter_parameter_logging is deprecated in favor of config.filter_parameters << :password.

ActiveRecord

  • named_scope in an Active Record class is deprecated and has been renamed to just scope.
  • save(false) is deprecated, in favor of save(:validate => false).
  • model.errors.on is deprecated in favor of model.errors[]
  • ActiveRecord::Base.colorize_logging and config.active_record.colorize_logging are deprecated in favor of Rails::LogSubscriber.colorize_logging or config.colorize_logging

ActionMailer

  • :charset, :content_type, :mime_version, :implicit_parts_order are all deprecated in favor of ActionMailer.default :key => value style declarations.
  • Mailer dynamic create_method_name and deliver_method_name are deprecated, just call method_name which now returns a Mail::Message object.
  • ActionMailer.deliver(message) is deprecated, just call message.deliver.
  • template_root is deprecated, pass options to a render call inside a proc from the format.mime_type method inside the mail generation block
  • The body method to define instance variables is deprecated (body {:ivar => value}), just declare instance variables in the method directly and they will be available in the view.
  • 不推荐使用app/models中的邮件程序,而是使用app/mailers.


Nat*_*ird 6

我认为您不会找到详尽的折旧列表,因为它实际上取决于您要升级的rails版本.例如,Rails 2.3.9(刚刚发布)在之前的版本中增加了额外的折旧.

Rails的升级手册(如上所述)是一个伟大的工具,并包含12页折旧警告和如何解决这些问题的.我不认为它们会在这里发布,因为你应该只需9美元并下载pdf即可获得列表.包含的教程和其他信息使它非常值得.这对我来说.

如果您不想为优质信息付费,那么只需为您的特定应用程序运行rails_upgrade插件.有关插件如何在rails升级插件github页面上的更多信息.

  • 支付这种通常免费的所有信息是绝对荒谬的. (3认同)