素晴らしい質問です。
ruby
1has_many :friendships
は実は
ruby
1has_many :friendships, :class_name => "Friendship", :foreign_key => "friendship_id",:primary_key=>"id"
を省略したもので
friendshipsと言う名前は、そのままで、わかりやすいのでつけているに過ぎず。
ruby
1has_many :hoges, :class_name => "Friendship", :foreign_key => "friendship_id",:primary_key=>"id"
としても、取ってくるhas_manyはなんら変わりません。
後ろが本体で、それが一致している時に省略できると言う風に考えてください。(正確には逆ですが)
あくまで、has_many等の後ろにくる最初の引数はassociationの名前と考えてください。
なので、modelをいちいち作成しなくてもclass_name,foreign_key等を調整したり
lamubda式を使って
ruby
1has_one :best_friend,->{where(friendships: {best: true})} :class_name => "Friendship", :foreign_key => "friendship_id",:primary_key=>"id"
のように新たなassociationが幾つでも作れます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。