-
-
Save rmehner/1438956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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