Turns out it''s pretty easy.
In item''s create view:
<%= file_field ''item'', ''file'' %>
and item''s model:
class Item < ActiveRecord::Base
validate :check_file_size
def check_file_size
if @file and @file.size > 20000
errors.add(''file'', ''too big'')
end
end
def file
@file
end
def file=(file)
@file=file
end
end
csn
--- Mikkel Bruun <mikkel-zZeBJi6nFjBknbxzx/v8hQ@public.gmane.org> wrote:
> cool_screen_name90001 wrote:
> > It appears there are no validation class methods that can be used on
> > file uploads? These would be
> > nice :)
> >
> > validates_file_type
> > validates_file_size
> >
> >
> > csn
> >
> >
> >
> > __________________________________
> > Yahoo! FareChase: Search multiple travel sites in one click.
> > http://farechase.yahoo.com
>
> Those validations would only make sense on a UploadedFileClass...As this
> class doesnt exsist in rails, there''s no need for these
validations in
> the core...
>
> But it would be an excellent code snippet...
>
> Mikkel
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com