Answers for "rails self-referential association must exist"

1

rails self relation

class MyModel < ActiveRecord::Base
  belongs_to :parent, :class_name => 'MyModel'
  has_many :children, :class_name => 'MyModel', :foreign_key => 'parent_id'
end
Posted by: Guest on May-23-2020

Code answers related to "rails self-referential association must exist"

Browse Popular Code Answers by Language