I think you try to parse the csv before saving the model to the db.
Thats when validations would be run. You should catch any FasterCSV
Exceptions and give a proper error message in the controller.

2009/10/8, John Mcleod <[email protected]>:
>
> Hello all,
> I'm trying to validate a uploaded file extension.  I'm not using any
> special plugin other that fastercsv.
>
> When I try to upload an incorrect file (say a ".doc"), I get this error
> message...
> "Error adding logs. (Unquoted fields do not allow \r or \n (line 2).).
> Please try again."
>
> Below is my model.
>
> -model-
> class Import < ActiveRecord::Base
>   validates_format_of :import, :with => /^.+\.(csv)$/,
>                       :message => 'A .csv file is required.'
> end
>
> It should work but it doesn't.
>
> Any help with this is greatly appreciated.
> Thank you.
>
> JohnM
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

-- 
Von meinen Mobilgerät aus gesendet

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to