Skip to content

Instantly share code, notes, and snippets.

View katpadi's full-sized avatar
🎯
Focusing

Kat Padilla katpadi

🎯
Focusing
View GitHub Profile
# use inverse_of to 'just work'
class User < ActiveRecord::Base
has_many :contributions, inverse_of: :user
has_many :posts, through: :contributions
end
class Post < ActiveRecord::Base
has_many :contributions, inverse_of: :post
has_many :contributors, through: :contributions,
source: :user