【问题标题】:Rails 4: Cookie overflow when importing CSVRails 4:导入 CSV 时 Cookie 溢出
【发布时间】:2016-05-21 01:19:06
【问题描述】:

我试图在导入我的数据库之前分析 CSV,但遇到了ActionDispatch::Cookies::CookieOverflow 错误。

控制器

def bulk_upload_weigh_ins
    @response = WeighIn.check_file(params[:file])
    redirect_to import_weigh_ins_path, notice: @response
end

型号

def self.check_file(file)
    status = {
        name_error: [],
        weigh_in_error: []
    }
    count = 0
    CSV.foreach(file.path, headers: @weigh_in_cols) do |row|
        hashed_row = row.to_hash
        user = User.find_by(scale_id: hashed_row["scale_id"])
        if user == nil
            status[:name_error] << [hashed_row["name"], hashed_row["scale_id"]]
        elsif user.check_ins.with_no_weigh_ins.length != 1
            status[:weigh_in_error] << [hashed_row["name"], hashed_row["scale_id"]]
        else
            count += 1
        end
        status[:number_of_success] = count
    end
    return status
end

我查看了this 的帖子,但我不确定我是否应该使用相同的修复方法。有没有更好的设置方法?

【问题讨论】:

    标签: ruby-on-rails csv ruby-on-rails-4 cookies


    【解决方案1】:

    我做了以下来解决这个问题:

    1. rails generate active_record:session_migration
    2. rake db:migrate
    3. 将 config/initializers/session_store.rb 中的行更改为:Rails.application.config.session_store :active_record_store
    4. 已被服务器重启
    5. 重新启动了我的浏览器(对我来说不是很明显)

    希望这对某人有所帮助

    【讨论】:

      猜你喜欢
      • 2016-08-15
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      相关资源
      最近更新 更多