Skip to content

Instantly share code, notes, and snippets.

@rmehner
Forked from mrnugget/gist:1438953
Created December 6, 2011 17:02
Show Gist options
  • Save rmehner/1438956 to your computer and use it in GitHub Desktop.
Save rmehner/1438956 to your computer and use it in GitHub Desktop.
class Song < ActiveRecord::Base
belongs_to :session
validates_presence_of :file_name
validate :file_name_has_to_be_audio
private
def file_name_has_to_be_audio
unless ['mp3', 'flac', 'wav'].include? file_name.split(".").last.downcase
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