Rails: Article.all works, class method therein does not -
how possible? article.all
works in console, method called self.retirement_collection
therein not. ideas?
class article < activerecord::base ... def self.retirement_collection articles = articles.all articles.each |article| if article.retirement_at < time.now article.retire end end end ... end
i nameerror
when type article.retirement_collection
console: nameerror: uninitialized constant article::articles
.
it looks mistyped article class when doing article.all
,
def self.retirement_collection articles = article.all # here articles.each |article| if article.retirement_at < time.now article.retire end end end
Comments
Post a Comment