mardi 5 septembre 2017

How to make Custom Association

class Order < ApplicationRecord
has_many :order_stages
has_many :stages , :through=> :order_stages
end
class Stage < ApplicationRecord
    has_many :order_stages
    has_many :orders , :through=> :order_stages
end
class OrderStage < ApplicationRecord
  belongs_to :order
  belongs_to :stage
end

these table has_many :through association . How to make the custom association to these table.

Aucun commentaire:

Enregistrer un commentaire