【问题标题】:Ruby, delayed_job, Roo - undefined method `name' for nil:NilClassRuby,delayed_job,Roo - nil:NilClass 的未定义方法“名称”
【发布时间】:2016-10-05 17:52:14
【问题描述】:

在我的控制器中

  def upload
    @file = params[:file_xlsx]
    Category.delay.upload_process(@file.tempfile, params[:id])
    redirect_to action: "show", id: params[:id]
  end

在我的模型上

  def self.upload_process(file, id)

    xlsx = Roo::Excelx.new(file)
    .........
  end

错误:

nil:NilClass 的未定义方法“名称”

没有“delayed_job”可以完美运行,但不能使用“delayed_job”,有什么问题?

【问题讨论】:

    标签: ruby delayed-job roo


    【解决方案1】:

    尝试Following.把delay放在最后

    def upload
      @file = params[:file_xlsx]
      Category.upload_process(@file, params[:id]).delay
      redirect_to action: "show", id: params[:id]
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-08
      • 2023-03-06
      • 2014-05-05
      • 1970-01-01
      相关资源
      最近更新 更多