【发布时间】:2017-06-23 00:09:51
【问题描述】:
在解释scope 的文档中,在下面的示例中两次调用作用域是做什么的?第一组就像Article.new('published': true),但第二组published 是做什么的?
class Article < ActiveRecord::Base
scope :published, -> { where(published: true) }
end
Article.published.new.published # => true
【问题讨论】:
标签: ruby-on-rails activerecord scope