2011-02-23 69 views
0

我有一個接受參數的rake任務:scope(below)。 我叫耙任務是這樣的:沒有被傳遞到Rake任務的參數

rake podcast:generate_inventory["new"] 

用來打發這個任務:範圍精氨酸完美,但是,我今天注意到,ARG不再被通過。有誰知道爲什麼會發生這種情況?

namespace :podcast do 

    task :itunes_top_300, [:scope] => :environment do |t,args| 
    Podcast.podcast_logger.info("BEGIN: #{Time.now}") 
    if args[:scope] == "new" 
     Podcast.podcast_logger.info("NEW PODCASTS ONLY") 
    end 
    Podcast.itunes_top_rss 
    end 

    task :itunes_genres_top_300 => :itunes_top_300 do 
    Podcast.itunes_genre_rss 
    end 

    task :site_and_feed_discovery, [:scope] => :itunes_genres_top_300 do |t,args| 
    if args[:scope] == "new" 
     Podcast.site_and_feed_discovery(:new_podcasts_only => true) 
    else 
     Podcast.site_and_feed_discovery 
    end 
    end 

    task :social_discovery, [:scope] => :site_and_feed_discovery do |t,args| 
    if args[:scope] == "new" 
     Podcast.social_discovery(:new_podcasts_only => true) 
    else 
     Podcast.social_discovery 
    end 
    end 

    task :fetch_episodes => :social_discovery do |t,args| 
    Episode.episode_logger.info("BEGIN: #{Time.now}") 
    Podcast.fetch_episodes 
    Episode.episode_logger.info("END: #{Time.now}") 
    end 

    task :generate_inventory => :fetch_episodes do |t,args| 
    Podcast.podcast_logger.info("Successful Rake") 
    Podcast.podcast_logger.info("END #{Time.now}") 
    Rake::Task['maintenance:daily'].invoke 
    end 
end 

回答

1

看起來像你缺少你的task :generate_inventory定義[:scope]位。我懷疑再加入這件事會照顧到一切。

希望有幫助!

+0

非常感謝Xavier。工作就像一個魅力:) – lightyrs 2011-02-26 00:21:38