Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Rails 中使用thoughtbot 的回形针,并希望允许上传任何文件类型,除非是明显危险的文件类型。validates_attachment_content_type 方法可以很容易地验证附件是否属于安全类型,但是否可以仅验证它不危险?
就在这里。
validates_attachment :image, :content_type => { :not => "application/zip" }
这将让您使用黑名单而不是白名单的概念。