File upload without entering the file

require 'rubygems'
    require 'spreadsheet'
    Spreadsheet.client_encoding = 'UTF-8'
     workbook = Spreadsheet.open params[:dump][:excel_file]
     sheet = workbook.worksheet 'database'

I am getting an error if i click on upload button with no file in the
field.

···

--
Posted via http://www.ruby-forum.com/.

And ? If your code assumes the existence of a param that's not being
provided, why is that a surprise?

···

On Wed, Aug 8, 2012 at 4:25 AM, deal bitte <lists@ruby-forum.com> wrote:

I am getting an error if i click on upload button with no file in the field.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan

Just check that params[:dump][:excel_file] exists before you use it.

You could also disable the upload button by default and enable it using
javascript only if they enter a value in the field.

···

On Aug 8, 2012 4:26 AM, "deal bitte" <lists@ruby-forum.com> wrote:

require 'rubygems'
    require 'spreadsheet'
    Spreadsheet.client_encoding = 'UTF-8'
     workbook = Spreadsheet.open params[:dump][:excel_file]
     sheet = workbook.worksheet 'database'

I am getting an error if i click on upload button with no file in the
field.

--
Posted via http://www.ruby-forum.com/\.

if params[:dump][:excel_file].blank?
      flash[:notice] = "Please provide a file to upload."
    else
my code

This does not work. I tried it before posting this problem.I have this
piece of code in my controller

Jonan S. wrote in post #1071675:

···

Just check that params[:dump][:excel_file] exists before you use it.

You could also disable the upload button by default and enable it using
javascript only if they enter a value in the field.

--
Posted via http://www.ruby-forum.com/\.