Thanks to Rich Peck's Answer i was able to solve my problem with this solution.
first of all use lambda to handle conditions
has_attached_file :file,
styles: lambda { |a| a.instance.check_file_type}
then i defined a custom method named check_file_type
in this method i did the validations and checking with ease based on this ruby best pratice article
def check_file_type
if is_image_type?
{:small => "x200>", :medium => "x300>", :large => "x400>"}
elsif is_video_type?
{
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10, :processors => [:ffmpeg] },
:medium => {:geometry => "250x150#", :format => 'jpg', :time => 10, :processors => [:ffmpeg]}
}
else
{}
end
end
and defined my is_image_type?
and is_video_type?
to handle for both videos and images.
def is_image_type?
file_content_type =~ %r(image)
end
def is_video_type?
file_content_type =~ %r(video)
end
then my attachment validation now looks like this
validates_attachment_content_type :file, :content_type => [/\Aimage\/.*\Z/, /\Avideo\/.*\Z/, /\Aaudio\/.*\Z/, /\Aapplication\/.*\Z/]
with this method, i can now use one paperclip method to handle multiple file types.