【发布时间】:2015-02-20 21:58:21
【问题描述】:
我正在使用 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"
对我(完全是初学者)来说,第一个似乎更清晰/更清晰。还是没关系?
【问题讨论】:
标签: ruby-on-rails ruby image paperclip-validation