【问题标题】:default_scope in rails 3rails 3中的default_scope
【发布时间】:2011-02-03 21:19:10
【问题描述】:

我知道 named_scope 已更改为 rails 3 中的范围。

如何在 Rails 3 中执行 default_scope,我有一个很好的 google,但没有找到默认范围。

【问题讨论】:

    标签: ruby-on-rails activerecord scope default-scope


    【解决方案1】:

    default_scope where(:abc => val)

    【讨论】:

      【解决方案2】:

      这是另一个指针:AR::Base.default_scope 的 api 文档

      【讨论】:

      【解决方案3】:

      默认范围在 Rails 3.0 中可用,见下文

      【讨论】:

      • default_scope 会保留在 rails3 中吗?它不会在未来的版本中被弃用?
      • 我在许多 Rails3 应用程序中使用 default_scope,但我没有看到弃用警告,所以我认为它会保留。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多