Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit belongs_to through #94

Open
Scaffale opened this issue Feb 11, 2020 · 0 comments
Open

Inherit belongs_to through #94

Scaffale opened this issue Feb 11, 2020 · 0 comments

Comments

@Scaffale
Copy link

Scaffale commented Feb 11, 2020

Using:

Rails 6.0.0
ruby 2.6.4

More a "how to" then an issue:

Class 1 (the top level class)

class AbstractResult < ApplicationRecord
  actable
  belongs_to :person
end

Class 2 (act_as abstract_result)

class TestResult < ApplicationRecord
  acts_as :abstract_result
  has_one :test_spatial_result, dependent: :destroy
end

Class 3 (belonging to class 2)

class TestSpatialResult < ApplicationRecord
  belongs_to :test_result
  has_one person, through: :test_result
end

Now, If I try

test_result.person

it works properly, but if I try

test_spatial_result.person

it won't work.

How can be done the inheritance of the belongs to through the polymorphic association?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant