I am using paperclip for uploading file ( video and images). Have used the same attachment(source) for both video and images.
class Media < ActiveRecord::Base
belongs_to :memory
validates_attachment_presence :source
validates_attachment_content_type :source,
:content_type => [ video/mp4 , image/png , image/jpeg , image/jpg , image/gif ]
end
现在我想在不同案件中显示不同的错误信息。
- When uploading file is image type but not the jpg/png/jpeg/gif.
- When uploaded file is video type but not the mp4
How can i achieve this ? Any help would highly appreciated.