vendredi 20 février 2015

Paperclip synatx; which way is the proper way of handling validates_attachment_content_type

I'm using the ruby gem paperclip to handle image attachments and I'm adding validates_attachment_content_type to my books model. I just have a question on syntax.


Which is the proper way of doing the above?


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"


or


validates_attachment_content_type :image, content_type: /^image\/(png|gif|jpeg|jpg)/, message: "Only jpeg, png, and gif images types are allowed"


To me (total beginner) the first seems cleaner/clearer. Or does it not matter?


Aucun commentaire:

Enregistrer un commentaire