I'm using roo-rb/roo to import csv files of data into my database. But with 55 rows, 4 columns, I am getting an ActionDispatch::Cookies::CookieOverflow error. Anyone know what could be causing this or what would be trying to create this cookie that I guess is maxing out?
Here is my import function:
def self.import(file)
result = {
errors: 0,
success: 0,
row_results: { }
}
spreadsheet = open_spreadsheet(file)
header = spreadsheet.row(1)
transaction do
(2..spreadsheet.last_row).each do |i|
row = Hash[[header, spreadsheet.row(i)].transpose]
file_row_hash = row.to_hash
first_name = file_row_hash['first_name']
last_name = file_row_hash['last_name']
company_name = file_row_hash['company_name']
email = file_row_hash['email']
company = Company.new(:name => company_name)
if company.save
password = Devise.friendly_token.first(8)
user = StaffMember.new({ :email => email, :encrypted_password => password, :first_name => first_name, :last_name => last_name, :company_id => company.id })
if user.save
result[:success] += 1
result[:row_results][i] = "row #{i}: #{company['name']} and #{company['first_name']} + #{company['last_name']} was successfully created"
else
result[:errors] += 1
result[:row_results][i] = "row #{i}: #{company['name']} saved BUT staff_member #{company['first_name']} + #{company['last_name']} failed to save"
end
else
result[:errors] += 1
result[:row_results][i] = "row #{i}: #{company['name']} and #{company['first_name']} + #{company['last_name']} failed to be created."
end
end
end
return result
end
You can solve this problem by changing the way your cookie is stored.
In config/initializers/session_store.rb
You should have something like:
Rails.application.config.session_store :cookie_store, key: 'YOUR_KEY'
Just change :cookie:store
to :active_record_store
like this:
Rails.application.config.session_store :active_record_store, :key => 'YOUR_KEY'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.