Skip to content

Instantly share code, notes, and snippets.

@SteveOscar
Created December 28, 2015 17:43
Show Gist options
  • Save SteveOscar/43a942ea6d814d30daf2 to your computer and use it in GitHub Desktop.
Save SteveOscar/43a942ea6d814d30daf2 to your computer and use it in GitHub Desktop.
Class Article < ActiveRecord::Base
has_many :article_newspapers
has_many :newspapers, :through => :article_newspapers
end
Class Newspaper < ActiveRecord::Base
has_many :article_newspapers
has_many :articles, :through => :article_newspapers
end
Class ArticleNewspaper < ActiveRecord::Base #the join table
belongs_to :article
belongs_to :newspaper
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment