I have an RSS Feed class, which holds the feed url, name, etc. and I want to add a posts method to loop through each post in the feed and returns the results. I have the following code, but am getting many SystemStackError: stack level too deep errors.
class Feed
field :name
field :url
belongs_to :project
def self.posts
results = []
scoped.all.each {|f| results << RssFeed.get(f.name, f.url)}
results
end
end
My application has different Projects, and each project has many feeds. So in my code I’m trying to get all posts from all rss feeds that belong to a particular project like this:
project.feeds.cached
I am able to call scoped in my posts method which will return a Mongoid::Criteria but scoped.all.each or scoped.entries both return stack level too deep errors. I was wondering how I can access the project.feeds scope from within my posts class method?
Thanks in advance!
My silly mistake –
cachedis a reserved word.