How would you check if a file is an image? I\'m thinking you could use an method like so:
def image?(file) file.to_s.include?(\".gif\") or file.to_s.includ
As an addition to Joel's answer, in Rails 5 I had to transform the comparison string to a bytecode. Eg:
def jpeg?(data) return data[0,4]=="\xff\xd8\xff\xe0".b end