Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Created December 6, 2011 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrnugget/1438953 to your computer and use it in GitHub Desktop.
Save mrnugget/1438953 to your computer and use it in GitHub Desktop.
class Song < ActiveRecord::Base
belongs_to :session
validates :file_name, :presence => true
validate :file_name_has_to_be_audio
def file_name_has_to_be_audio
unless ['mp3', 'MP3', 'flac', 'FLAC', 'wav', 'WAV'].include? file_name.split(".").last
errors.add(:file_name, "has to be mp3/flac/wav file")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment