Answers for "many to many relationships rails"

0

rails many to many relationship same model

class Page < ActiveRecord::Base

  has_many :left_page_associations, :foreign_key => :left_page_id,
           :class_name => 'PageAssociation'
  has_many :left_associations, :through => :left_page_associations,
           :source => :right_page
  has_many :right_page_associations, :foreign_key => :right_page_id,
           :class_name => 'PageAssociation'
  has_many :right_associations, :through => :right_page_associations,
           :source => :left_page

end
Posted by: Guest on March-10-2020

Code answers related to "many to many relationships rails"

Browse Popular Code Answers by Language