我正在使用 ruby gem 回形针来处理图像附件,并且正在添加validates_attachment_content_type
到我的书籍模型中。我只是对语法有疑问。
执行上述操作的正确方法是什么?
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"], message: "Only jpeg, png, and gif images types are allowed"
或者
validates_attachment_content_type :image, content_type: /^image\/(png|gif|jpeg|jpg)/, message: "Only jpeg, png, and gif images types are allowed"
对我(完全是初学者)来说,第一个似乎更干净/更清晰。还是没关系?