开发者

ActiveRecord and has_many, :through link backs

开发者 https://www.devze.com 2023-01-07 12:36 出处:网络
Is there a simple way to specify a has_many :through relationship where you\'re linking the same data type? eg. One User has many friends (who are all users).

Is there a simple way to specify a has_many :through relationship where you're linking the same data type? eg. One User has many friends (who are all users). I'd like to be able to store data about the friendship, so has_many :through seems to be the obvious choice, but then you'd have to define two :user_id columns, which of course doesn'开发者_Python百科t really work…


This Self-referential association screencast by Ryan Bates sounds like it was made for your situation.

0

精彩评论

暂无评论...
验证码 换一张
取 消