I am trying to export a table which has over 100,000 rows
def export
export_data = []
MyModel.uncached do
MyModel.find_each do |s|
export_data << {
:col1 => s.col1,
:col2 => s.col2,
:col3 => s.col3,
:col4 => s.col4
}
end
end
export_data = {:export_data => export_data }
send_data export_data.to_json, :type => :json, :disposition => "attachment", :filename => "export_data.json"
end
When I hit this action using a url_path it is taking very long time to process the request and also the file downloaded is around 80MB.
What is the proper way to approach this problem so that the user need not wait for the request to complete?