You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm stuck with defining a search field on an attribute that is in a second level polymorphic association. Let me explain:
Given these models
class UserCase < ApplicationRecord
delegated_type :user_caseable, types: %w( WorkCase HobbyCase ), dependent: :destroy
end
class WorkCase < ApplicationRecord
delegated_type :work_caseable, types: %w( CaretakerCase OtherWorkerCase ), dependent: :destroy
end
class CaretakerCase < ApplicationRecord
# has a column named work_modality
end
I want to perform a search of user cases where they work_modality column of CartakerCase equals "intern".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm stuck with defining a search field on an attribute that is in a second level polymorphic association. Let me explain:
Given these models
I want to perform a search of user cases where they work_modality column of CartakerCase equals "intern".
What should the form field be named?
I tried this
In my view:
In my controller:
And I get this error when rendering the view:
"Polymorphic associations do not support computing the class"
What is the correct name for the field?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions