Rails 3不推荐使用的方法和API [英] Rails 3 deprecated methods and APIs

查看:72
本文介绍了Rails 3不推荐使用的方法和API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Where can one find a list of deprecated methods, APIs, etc, in order to upgrade from Rails 2.x to Rails 3?

推荐答案

Rails 3发行说明有很多有用的信息:

现在不再支持铁路


  • RAILS_ROOT而支持Rails.root,

  • RAILS_ENV赞成Rails.env,

  • RAILS_DEFAULT_LOGGER赞成Rails.logger。

ActionController:

ActionController:


  • 已弃用cookie_verifier_secret,现在通过Rails.application为它分配了
    。 config.cookie_secret并移至其自己的文件中:
    config / initializers / cookie_verification_secret.rb。

  • filter_parameter_logging已过时,取而代之的是
    config.filter_parameters<< :密码。

ActiveRecord

ActiveRecord


  • named_scope

  • save(false)已被弃用,而倾向于save(:validate => false)。
  • $不推荐使用b $ b
  • model.errors.on,而推荐使用model.errors []
  • 不推荐使用
  • ActiveRecord :: Base.colorize_logging和config.active_record.colorize_logging,而推荐使用Rails :: LogSubscriber.colorize_logging或config.colorize_logging

  • 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

ActionMailer


  • :charset,:content_type,:mime_version,:implicit_parts_order不推荐使用,而推荐使用ActionMailer.default:key =>值样式声明。

  • 邮件程序动态create_method_name和deliver_method_name是不推荐使用,只需调用method_name即可,该方法现在返回Mail :: Message对象。

  • 不推荐使用ActionMailer.deliver(message),只需调用message.deliver。

  • template_root已弃用已过时,将选项从邮件生成块内的format.mime_type方法传递给proc内部的渲染调用

  • 不推荐使用用于定义实例变量的body方法(body {:ivar => value }),只需直接在方法中声明实例变量,它们就可以在视图中使用。

  • 不推荐使用app / models中的邮件程序,而应使用app / mailers。

  • :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.
  • Mailers being in app/models is deprecated, use app/mailers instead.

这篇关于Rails 3不推荐使用的方法和API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆