Skip to content

Instantly share code, notes, and snippets.

View bousquet's full-sized avatar

Robert Bousquet bousquet

View GitHub Profile
class User < ActiveRecord::Base
has_many :collection_tracks
has_many :tracks, through: :collection_tracks
def collection
tracks
end
def add_to_collection(track)
collection_tracks.where(track_id: track.id).first_or_create