Reputation: 1011
I have a polymorphic resource in my rails app :
class Media < ActiveRecord::Base
# some stuff
belongs_to :mediable, :polymorphic => true
# some stuff
class Media::TeaserCroppedImage < Media
has_attached_file :attachment,
:styles => ...,
:processors => ...,
:path => "...",
:url => "...",
# ...
validates_attachment :attachment, matches: { file_name: ["image/jpeg", "image/jpg"] }
As you can see, I tried to add the paperclip validator. But apparently, it doesn't work, and I still get the error MissingRequiredValidatorError.
Is there a problem with the syntax of the validator ?
Upvotes: 1
Views: 432
Reputation: 34318
You have to have to include a content_type validation, something like this:
validates_attachment_content_type :attachment, :content_type => ["image/jpg", "image/jpeg"]
or you can replace your current validation with this:
validates_attachment_file_name :attachment, :matches => [/jpe?g\Z/]
Upvotes: 1