Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Song Model
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
You can’t perform that action at this time.