Hi, thr's a strange behavior with attachment_fu. when i upload a file, sometimes it gets uploaded without prb/error msg and sometimes the same file gives the error as size error msg. particularly, when i upload the next file immediately after another. can anybody help me in this? thanks in advance...
this is my mugshots model:- class Mugshot < ActiveRecord::Base has_attachment :content_type => ['application/vnd.ms-excel'], :storage => :file_system, :max_size => 5.megabytes, :path_prefix=>'public/temp_files' # validates_as_attachment def validate errors.add_to_base("You must choose a file to upload") unless self.filename unless self.filename == nil # Images should only be GIF, JPEG, or PNG [:content_type].each do |attr_name| enum = attachment_options[attr_name] unless enum.nil? || enum.include?(send(attr_name)) errors.add_to_base("You can only upload .xls file") end end # Images should be less than 5 MB [:size].each do |attr_name| enum = attachment_options[attr_name] unless enum.nil? || enum.include?(send(attr_name)) errors.add_to_base("file size should be smaller than 5 MB in size") end end end end end
-Dhaval