ruby on rails 3 - Loading feeds / entries getting undefined method 'entries' for 0:fixnum error -



ruby on rails 3 - Loading feeds / entries getting undefined method 'entries' for 0:fixnum error -

i trying load feeds blog resulting in error in title mentioned.

the error message:

nomethoderror (undefined method `entries' 0:fixnum): app/controllers/pages_controller.rb:6:in `home'

this how i'm doing:

i created file in libfolder called blog_feeds.rb, contains following:

module blogfeeds require 'feedzirra' def load_feeds feeds = feedzirra::feed.fetch_and_parse('http://blog.shigotodoko.com/feed') end end

and line #6 error is:

@feeds = load_feeds.entries

note error occurs sometimes, not always.

so, thought what's going wrong here?

thank you!

when fetching feed, feedzirra homecoming http status code instead of object containing feed entries, if http fetch results in error (i.e. not 200 or 3xx).

in order handle status gracefully, check type of object fetch_and_parse wrapping in like:

unless feeds.is_a?(fixnum) # work feeds object else # handle error condition, retry, etc. end

you should able see these failures fetching feed in browser repeatedly, if it's frequent enough.

ruby-on-rails-3 parsing feeds feedzirra

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -