📜  rails self 关系 - Ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:49.554000             🧑  作者: Mango

代码示例1
class MyModel < ActiveRecord::Base
  belongs_to :parent, :class_name => 'MyModel'
  has_many :children, :class_name => 'MyModel', :foreign_key => 'parent_id'
end