I trying to load feeds from my blog but this is resulting in the error in the title mentioned.
The error message:
NoMethodError (undefined method `entries' for 0:Fixnum):
app/controllers/pages_controller.rb:6:in `home'
This is how I'm doing:
I created a file in the lib
folder called blog_feeds.rb
, that contains only the following:
module BlogFeeds
require 'feedzirra'
def load_feeds
feeds = Feedzirra::Feed.fetch_and_parse('http://blog.shigotodoko.com/feed')
end
end
And the line #6 for the error is:
@feeds = load_feeds.entries
Note that this error only occurs sometimes, not always.
So, any idea about what's going wrong here?
Thank you!
Well, seems that was something wrong with my code before.
I was trying to randomize some posts and using something like this on the view:
In order to get the first 5 random posts.
And to fix it, I just replaced the
shuffle!
method for theshuffle
method.Now, everything is working fine!