ruby-on-railsactiverecordfeedzirra

Rails: Get urls from database?


Trying to get into Rails and feedzirra! :) I have stores multiple feed urls into database and have problems to fetch those and get it work feedzirra. Urls needs to be like this:

feed_urls = ["http://www.feedurl1.com/feed", "http://www.feedurl2.com/feed"]

This is what I got now but it is not working? Why?

  def self.get_feeds
     feed_urls = Feedurls.find(:all, :select => "url")
     update_from_feeds(feed_urls)
  end

Console puts me this:

ruby-1.9.2-p290 :037 > FeedEntry.get_feeds
Feedurls Load (0.6ms)  SELECT url FROM `feedurls` 
TypeError: can't convert nil into String

Thanks for all help! :)


Solution

  • Why not just simply use:

    feed_urls = Feedurls.all.map(&:url)
    

    If your feedurls is simple table (and it should be), then the code above will work nice.