我正在使用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" %>
配置/路由.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(请求工人类)
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 模板?任何重构技巧也将不胜感激。