Skip to content

Instantly share code, notes, and snippets.

Created June 27, 2014 21:51
Show Gist options
  • Save anonymous/98296ce3f93d5fa53884 to your computer and use it in GitHub Desktop.
Save anonymous/98296ce3f93d5fa53884 to your computer and use it in GitHub Desktop.
Active Record Associations
class User < ActiveRecord::Base
has_one :collection
has_many :tracks, :through => "collection"
end
class Collection < ActiveRecord::Base
belongs_to :user
has_many :tracks
end
class Track < ActiveRecord::Base
belongs_to :collection
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment