0

我需要将 msg 文件附加到 rails,我已经为 msg 文件类型添加了 mime 类型

validates_attachment :file, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif", "application/pdf","application/vnd.ms-excel",     
         "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
         "application/msword",
         "application/vnd.ms-outlook", 
         "application/octet-stream",
         "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 
         "text/plain"] }

但是当使用示例味精文件上传时,它出错了

Command :: file -b --mime '/tmp/5e8ff9bf55ba3508199d22e984129be620170527-6239-gqgnhz.msg'
Command :: file -b --mime '/tmp/5e8ff9bf55ba3508199d22e984129be620170527-6239-g903st.msg'
(0.2ms)  ROLLBACK
Completed 500 Internal Server Error in 26ms (ActiveRecord: 1.7ms)

有什么建议吗?我正在使用回形针 5.1.0

4

1 回答 1

0

什么是 Rails 验证错误?

if object.save
  ... 
else 
  logger.debug object.errors.inspect 
end

阅读导致回滚的保存错误,从那里您将知道它被拒绝的原因。

于 2017-05-31T04:54:44.453 回答