Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

relations regulate not working #110

Open
johansmitsnl opened this issue Aug 14, 2018 · 0 comments
Open

relations regulate not working #110

johansmitsnl opened this issue Aug 14, 2018 · 0 comments
Labels

Comments

@johansmitsnl
Copy link
Contributor

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant