Import Excel into Rails app
Posted
by Jack
on Stack Overflow
See other posts from Stack Overflow
or by Jack
Published on 2010-05-12T09:31:54Z
Indexed on
2010/05/12
11:44 UTC
Read the original article
Hit count: 151
Hi,
I am creating a small rails app for personal use and would like to be able to upload excel files to later be validated and added to the database. I had this working previously with csv files, but this has since become impractical.
Does anyone know of a tutorial for using the roo or spreadsheet gem to upload the file, display the contents to the user and then add to the database (after validating)? I know this is quite specific, but I want to work through this step by step.
All I have so far is an 'import' view:
<% form_for :dump, :url=>{:controller=>"students", :action=>"student_import"}, :html => { :multipart => true } do |f| -%>
Select an Excel File :
<%= f.file_field :excel_file -%>
<%= submit_tag 'Submit' -%>
<% end -%>
But have no idea how to access this uploaded file in the controller.
Any suggestions/help would be welcomed. Thanks
© Stack Overflow or respective owner