This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
relations regulate not working #110
Open
Description
Structure question
I'm trying to implement a offer calculator.
I have a structure in the database:
class SubscriptionOffer < ApplicationRecord
has_many :subjects, class_name: 'SubscriptionOffer::Subject'
end
class SubscriptionOffer::Subject < ApplicationRecord
belongs_to :offer, class_name: 'SubscriptionOffer', foreign_key: :subscription_offer_id
has_many :items, class_name: 'SubscriptionOffer::Subject::Item', foreign_key: :subscription_offer_subject_id
end
class SubscriptionOffer::Subject::Item < ApplicationRecord
belongs_to :subject, class_name: 'SubscriptionOffer::Subject', foreign_key: :subscription_offer_subject_id
end
The component:
SubscriptionOffer.last.subjects.each do |subject|
DIV do
subject.component
end
end
Adding regulate will make it work:
class SubscriptionOffer < ApplicationRecord
has_many :subjects, class_name: 'SubscriptionOffer::Subject', regulate: :always_allow
end