paperclip-validation

no validates_attachment_file_name when upgrading to Paperclip 4.1 from 3.5

时光总嘲笑我的痴心妄想 提交于 2019-12-05 19:49:05
We have code that looks like run of the mill paper clip: has_merchants_attached_file :pdf, storage: :s3, s3_credentials: Mbc::DataStore.s3_credentials, s3_permissions: :private, path: ":identifier_template.pdf", bucket: Mbc::DataStore.forms_and_templates_bucket_name validates_attachment_file_name :pdf, :matches => [/pdf\Z/] Which generates an error: undefined method `validates_attachment_file_name' for #<Class:0x007fba67d25fe0> Interestingly enough, when we down grade back to 3.5, we encounter the same issue. The controller that is generating this is: def index @fidelity_templates =

Validate extension in Paperclip - Ruby on Rails

倖福魔咒の 提交于 2019-11-30 18:53:31
I've found that Paperclip can validate file content type, i.e. image/jpeg, but I want to specifically validate the extension. This is because I'm working with an obscure extension that won't get a consistent content type. Anyone know if this is doable, or a good way to do this? Guess, there is no need to validate it with paperclip's method. You can rather use something like: has_attached_file :attachment validates_format_of :attachment_file_name, :with => %r{\.(docx|doc|pdf)$}i Edit: Alternatively, to validate it with paperclip: validates_attachment_content_type :attachment, :content_type =>

Paperclip in Rails 4 - Strong Parameters Forbidden Attributes Error

旧街凉风 提交于 2019-11-29 04:04:19
Having a problem with a Paperclip upload in Rails 4 - failing on ForbiddenAttributesError (strong parameters validation). Have the latest paperclip gem and latest rails 4 gems. I have a model "Image" with an attached file "upload" in the model: has_attached_file :upload, :styles => { :review => ["1000x1200>", :png], :thumb => ["100x100>", :png]}, :default_url => "/images/:style/missing.png" The image model was created with a scaffold, and I added paperclip migrations. The form partial was updated to use f.file_field :upload the form generates what appears to be a typical set of paperclip

Paperclip in Rails 4 - Strong Parameters Forbidden Attributes Error

南楼画角 提交于 2019-11-27 18:03:47
问题 Having a problem with a Paperclip upload in Rails 4 - failing on ForbiddenAttributesError (strong parameters validation). Have the latest paperclip gem and latest rails 4 gems. I have a model "Image" with an attached file "upload" in the model: has_attached_file :upload, :styles => { :review => ["1000x1200>", :png], :thumb => ["100x100>", :png]}, :default_url => "/images/:style/missing.png" The image model was created with a scaffold, and I added paperclip migrations. The form partial was