exception - Rescue won't rescue in Rails -
i'm writing simple app processes post
ed csv files , testing against invalid input (e.g. non-csv files). i'm using csv::reader.parse command parse csv in controller method, follows:
@parsed_file = csv::reader.parse(params[:file]) rescue []
however, despite rescue statement, i'm still getting uncaught csv::illegalformaterror
when improper submissions entered. missing here?
thanks!
you need pass file handle parse:
@parsed_file = csv::reader.parse(file.open(params[:file], 'rb')) rescue []
Comments
Post a Comment