validation - Ruby On Rails: How to validate a form having file upload field with other fields -



validation - Ruby On Rails: How to validate a form having file upload field with other fields -

i new ruby on rails(rails 3). having form 3 fields , among these 3 field, 1 field upload files(rar/tar/zip). know way validate (server side) such form allow user:-

1. fill in 3 fields. 2. uploaded file should either rar/tar/zip. 3. uploaded file should not exceed 2mb in size.

u can utilize paperclip gem uploading file.

class user < activerecord::base attr_accessible :avatar has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } end

there validations like

validates_attachment :avatar, :presence => true, :content_type => { :content_type => "image/jpg" }, :size => { :in => 0..10.kilobytes}

see https://github.com/thoughtbot/paperclip more info.

ruby-on-rails validation file-upload

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -