ruby on rails - How to update attributes -
i have problem update attributs. try update via cron.
sheduler.rb
every 3.minutes runner "update_from_feed_continuously(feed_url)" end
feed_entry.rb
class feedentry < activerecord::base attr_accessible :guid, :name, :url, :feed_url after_create { |feed| feedentry.update_from_feed(feed.feed_url) } def self.update_from_feed(feed_url) feed = feedzirra::feed.fetch_and_parse(feed_url) add_entries(feed.entries) end def self.update_from_feed_continuously(feed_url) feed = feedzirra::feed.update(feed) add_entries(feed.new_entries) if feed.updated? end private def self.add_entries(entries) entries.each |entry| unless exists? :guid => entry.id create!( :name => entry.title, :url => entry.url, :guid => entry.id ) end end end end
i use gem feedzirra , gem whenever
loading development environment (rails 3.2.13) 1.9.3p392 :001 > feedentry.update_from_feed_continuously(feed_url) nameerror: undefined local variable or method `feed_url' main:object (irb):1 /users/ipatov/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start' /users/ipatov/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start' /users/ipatov/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>' script/rails:6:in `require' script/rails:6:in `<main>'
1.9.3p392 :002 >
i trying ipmplement railscast http://railscasts.com/episodes/168-feed-parsing. tried load feed_url through console , update via cron
Comments
Post a Comment