ruby on rails - custom paperclip validation error message -


i have validation content type:

validates_attachment_content_type :photo, :content_type => /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/, :message => 'file type not allowed (only jpeg/png/gif images)' 

i want message above displayed instead says

 photos photo content type file type not allowed (only jpeg/png/gif images) 

because photos model , attached file photo.

thanks

> not real solution easy 1 skip paperclip validation , > write custom 1 >     validate :check_content_type >      >       def check_content_type >        if !['image/jpeg', 'image/gif','image/png'].include?(self.image_content_type) >         errors.add_to_base("file '#{self.image_file_name}' not valid image type") # or errors.add >        end >       end 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -