Created
July 24, 2012 08:11
-
-
Save freshfey/3168759 to your computer and use it in GitHub Desktop.
Song Model
This file contains hidden or 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 :user | |
acts_as_voteable | |
has_attached_file :music, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml" | |
validates_attachment_content_type :music, :content_type => ['application/mp3', 'application/x-mp3', 'audio/mpeg', 'audio/mp3' ], | |
:message => 'file must be of filetype .mp3!' | |
validates_attachment_size :music, :less_than => 10.megabytes | |
def previous_song | |
self.class.first(:conditions => ["created_at < ?", created_at], :order => "created_at desc") | |
end | |
def next_song | |
self.class.first(:conditions => ["created_at > ?", created_at], :order => "created_at asc") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment