Once a month or so, I’d like to pull data from an RSS feed and add it
into my database. I’ve written a rake task that properly reads the
feed, parses it and assigns the correct information to new instances
of my @event model - when I run the rake task and have it print out
the various @event attributes, they’re correct. However, when I
include the command @event.save nothing happens.
In fact, when I added this code
if @event.save
puts “Event saved”
else
puts “Event not saved, bummer”
I got “Event not saved, bummer”
Is it possible to use a rake task to add entries to my application’s
database? If so, any suggestions as to what I might be doing wrong?
I’m testing this in my development environment, and I start my task
definition using
task (:parse_info => :environment) do
Any suggestions would be greatly appreciated. Thanks.