1

I am attempting to analyze CSV before importing into my database but am encountering a ActionDispatch::Cookies::CookieOverflow error.

controller

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

model

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

I've looked at this post but I'm not sure I should be using doing the same fix. Is there a better way to set this up?

Community
  • 1
  • 1
Jeremy Thomas
  • 6,240
  • 9
  • 47
  • 92

1 Answers1

1

I did the following to fix this:

  1. rails generate active_record:session_migration
  2. rake db:migrate
  3. Changed the line in config/initializers/session_store.rb to: Rails.application.config.session_store :active_record_store
  4. Restarted by server
  5. Restarted my browser (wasn't obvious to me)

Hope this helps someone

Jeremy Thomas
  • 6,240
  • 9
  • 47
  • 92