I am using Ruby on Rails 3.2.2 and I would like to know if it is possible to run a method on each record retrieved when "running" / "loading" an ActiveRecord::Relation
so to "keep" / "return" only those records for which that method returns true
until those are 5. That is, I have:
class Comment < ActiveRecord::Base
def method_name
# return 'true' or 'false'
end
end
# The '<...>' in the below code could / should be stated to run the 'method_name'
# on each comment and keep those comments for which 'method_name' returns 'true'
# until the count of retrieved comments is 5.
Comment.where(:published => true).<...>
Comment.<...>