Forum: Ruby on Rails named_scope with instance methods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C9a5c1a060b4c97a5455c09a1845fc90?d=identicon&s=25 Bart Zonneveld (haedjin)
on 2009-01-16 14:05
Hey all,

Imagine I'm writing a weblog with a RSS feeds. I only want the active
articles to be in the RSS feed. Articles have a fairly complex method to
define whether they active, which is pretty hard to convert to find
attributes. Besides, I already have defined that method...
So, is there a way to use instance methods in a named_scope? Something
like

named_scope :rss, :order => "created_at DESC", :limit => 25, :if =>
Proc.new { |a| a.active? }

thanks!
This topic is locked and can not be replied to.