app/models/photo.rb
# Override the crappy default AttachmentFu error messages.
Override the crappy default AttachmentFu error messages.
Override the crappy default AttachmentFu error messages .
def validate
    if filename.nil?
      errors.add_to_base("請選擇你要上傳的圖片檔案")
    else
      enum = attachment_options[:content_type]
      unless enum.nil? || enum.include?(send(:content_type))
        errors.add_to_base("抱歉！你只能上傳 GIF, JPEG 或 PNG 格式的相片")
      end
      enum = attachment_options[:size]
      unless enum.nil? || enum.include?(send(:size))
        msg = "抱歉！上傳的相片檔案最大不可超過 #{UPLOAD_LIMIT} MB"
        errors.add_to_base(msg)
      end
    end
  end
def validate if filename . nil? errors . add_to_base ( "請選擇你要上傳的圖片檔案") else enum = attachment_options [ :content_type ] unless enum . nil? || enum . include? ( send ( :content_type ) ) errors . add_to_base ( "抱歉！你只能上傳 GIF, JPEG 或 PNG 格式的相片") end enum = attachment_options [ :size ] unless enum . nil? || enum . include? ( send ( :size ) ) msg = "抱歉！上傳的相片檔案最大不可超過 #{UPLOAD_LIMIT} MB" errors . add_to_base ( msg ) end end end
Override the crappy default AttachmentFu error messages.
Override the crappy default AttachmentFu error messages .
# Images should only be GIF, JPEG, or PNG # Images should be less than UPLOAD_LIMIT MB.