I have a form for uploading an excel file, and a method that parses said file using Roo. What I want to happen is this: user uploads excel file, and is redirected to a page that lists the first ten lines of the file.
I can get the first ten lines, but I can't figure out how to get them past the first method. I tried including them in the params, but I get a "Request-URI Too Large" error, unsurprisingly. This is what I have so far:
def upload_file
# View with form. User adds file, which is uploaded under "file" params.
end
def process_file
file_path = params[:file].path
@lines = Roo::Excelx.new(file_path).first(10).to_a # Returns array of first ten lines of file
? # Somehow save value of @lines for "view_lines" method
redirect_to view_lines_path
end
def view_lines
@lines = ? # I want to use the "@lines" array from the previous method here.
...
So to be clear, I want to take the @lines
value (which is an array of ten arrays) from the process_file
method, and pass it through to the view_lines
method. But it's too big to pass with params. Do I have to resort to using ajax?