resque gem とbiorubyでバックグラウンド処理を使用していますが、処理は正しく機能しています。ただし、「テンプレートがありません」というエラーが発生します。アクションがテンプレートをロードしようとしているようです。
Missing template cosmics/start_batch, application/start_batch with {:locale=>[:en],
:formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
テンプレートをロードしたくない: バックグラウンド プロセスが外部ソースからデータを取得し、データベース テーブルを更新します (これはすべて機能しています)。
コードはボタンによってトリガーされます。
<%= link_to 'Process', start_batch_path, :class =>"btn btn-primary" %>
config/routes.rb
match '/cosmics/start_batch', :to => 'cosmics#start_batch', :as => 'start_batch'
resources :batches do
resources :batch_details
end
cosmics_controller.rb
def start_batch
@batch = Batch.create!(:status => 'created',:status_timestamp => Time.now)
@cosmics = Cosmic.find(:all, :conditions => {:selected => true}).each do |cosmic|
@batch_detail = BatchDetail.create!(:batch_id => @batch.id, :cosmic_mut_id => cosmic.cosmic_mut_id)
@batch_detail.save
cosmic.selected = false
cosmic.save
end
Resque.enqueue(UcscQuery,@batch.id)
end
workers/ucsc_query.rb (reqsue ワーカー クラス)
class UcscQuery
require 'bio-ucsc'
include Bio
@queue = :ucsc_queue
def self.perform(batch_id)
Ucsc::Hg19.connect
@batch_detail = BatchDetail.find(:all, :conditions => {:batch_id => batch_id}).each do |batch_detail|
ucsc_cosmic = Ucsc::Hg19::Cosmic.find_by_name(batch_detail.cosmic_mut_id)
if ucsc_cosmic
batch_detail.bin = ucsc_cosmic.bin
batch_detail.chrom = ucsc_cosmic.chrom
batch_detail.chrom_start = ucsc_cosmic.chromStart
batch_detail.chrom_end = ucsc_cosmic.chromEnd
batch_detail.status = 'processed'
batch_detail.save
end
end
Batch.update(batch_id, :status => 'located')
end
end
Rails が cosmics/start_batch テンプレートを読み込もうとするのを防ぐにはどうすればよいですか? リファクタリングのヒントもいただければ幸いです。