Open cyu opened 2 months ago
Thanks @cyu! @gabrielgiroe1 will investigate this shortly.
Related to https://github.com/avo-hq/avo/issues/2651
I did look into this a bit, and the issue seems to be how IndexComponent
checks field_linked_to_child_resource?
on the ID field when it should be checking on the has_many
field.
Ok. That might be the fix! Would you be open to try and send in a fix?
@adrianthedev I can give it a shot, but I need some guidance on how to navigate to the parent has_many field in that scenario.
Hey @cyu can you please confirm if it works or not on the demo website? https://avodemo.com/avo/resources/people
I think I see it working.
https://github.com/avo-hq/avo/assets/1334409/3dc3cefd-0025-48f7-ba53-5ac7e80e284b
@adrianthedev It works from the People index view; where it doesn't work is from a child view.
For example, if you add to Person has_many :parents, class_name: "Person"
, and then add a has_many
field for family
on the Person
resource.
Can you please create a reproduction repo so we can test it out?
@adrianthedev https://github.com/cyu/avo-test
The issue arises when you create a Person
without specifying a type
and then attach a child to this Person
. When you click on theID
of the Person,
you expect to be redirected to the child, but this does not happen because the Person
does not have a type
defined.
Hi, @cyu! I did some more digging and managed to reproduce the bug you were describing. that bug is fixed in Avo 3. Avo 2 is not receiving any more bug fixes, but only security fixes.
I will close this to keep the issue queue clean. Let me know if there's anything else I can help with.
@gabrielgiroe1 What version of Avo 3 is this in? My repro example was done in Avo 3.7.4
Please re-review this issue and the example repro project. I don't believe this is solved. It doesn't make sense that the ID link had the view link would behave differently in this case.
I misunderstood that it would be on Avo 2. We will look to check if it is fixed.
This issue has been marked as stale because there was no activity for the past 15 days.
Describe the bug
The ID field within a
has_many
field always links to the base class resource even whenlink_to_child_resource
is true.Steps to Reproduce
Steps to reproduce the behavior:
Consider having the setup in the STI example here: https://docs.avohq.io/2.0/associations.html#link-to-child-resource-when-using-sti
avo.rb
initializer, enableid_links_to_resource
:config.id_links_to_resource = true
peoples
fieldExpected behavior & Actual behavior
When you click on the linked ID column, the expectation is that it will take you to the show page of the child resource (SpouseResource or SiblingResource). Instead it takes you to the base class resource (PersonResoure). If you use the View icon button, it will actually take you to the correct child record.
System configuration
Avo version: 3.3.2
Rails version: 7.1 3
Ruby version: 3.2.2
License type:
Are you using Avo monkey patches, overriding views or view components?
Screenshots or screen recordings
Additional context
Impact
Urgency