我有以下脚本,我想自动更新我的数据库。
require 'feedzirra'
require 'sanitize'
namespace :db do
task :update_pitzer => :environment do
feed = Feedzirra::Feed.fetch_and_parse('http://www.cafebonappetit.com/rss/menu/219')
feed.entries.each do |entry|
date = Sanitize::clean(entry.title)
summary = Sanitize::clean(entry.summary)
summary.gsub!(/\s{2}/, " ").to_s
summary.gsub!(/\s{2}/, "").to_s
summary.gsub!("&", "&")
puts "#{date}"
theDay = Day.create(date: date)
#theDay.collins_meals.create()
array = summary.split(/\[/)
array.collect! {|x| "[" + x}
array.reject! {|x| x == "[ "}
array.to_s
puts array
end
end
end
当我在命令行运行 rake db:update_pitzer 时,我得到:
(in /Users/Alex/rails_projects/dining_hall_api)
rake aborted!
Don't know how to build task 'db:update_pitzer'
想法?