“Rails 会寻找名为 _id 的外键,其中 是模型类名的小写形式。”
user.rb
has_many :microposts, dependent: :destroy
has_many :active_relationships, class_name: "Relationship",
foreign_key: "follower_id",
dependent: :destroy
既然可以用 foreign_key 指明外键,那 class_name 有什么用啊?