-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Apply link_to_child_resource
on associations.
#2651
Comments
This issue has been marked as stale because there was no activity for the past 15 days. |
Any progress on this issue? The documentation seems to imply that this should work: https://docs.avohq.io/3.0/associations.html#link-to-child-resource-when-using-sti |
Not really, sorry about that. Do you think you could lend a hand and maybe check if you could submit a PR? Thank you! |
@adrianthedev Doing some digging into the code, here's what I've discovered. When deciding on the link to the record, the determination of whether to link to a child resource is made based on the There is some sort of pseudo-field being called for the association itself, which is where the |
It looks like the edit/show buttons are using the association "field" to determine whether to link to the child resource. So, they obey So it comes down to: What is the expected behavior of It seems to me it should be punting over to that association to make the determination, but I feel like this is... going to get a little gnarly logic-wise and am hesitant to try and hack something together for it. I'll take a quick stab and see what I come up with. |
@adrianthedev It seems to me -- and I of course could be wildly misunderstanding things -- that basically in If that condition is true, you need to consult a different field. Specifically, the "field" that's being consulted for rendering the show/edit buttons. And the behavior of that is... kinda weird. It seems to me more flexible / less surprising behavior would be to list to My hangup in contributing a PR is that I don't know how to get access to that association field object from |
@adrianthedev Ok. So. This is... more or less Doing The Thing in my testing. I'm 100% sure that it's not the right way to look up the field object though, because I'm doing some monkey-patching that renames def parent_or_child_resource
if field.present? && field.is_a?(Avo::Fields::IdField) && @parent_record.present?
parent_field = parent_resource.fields_by_database_id[params["related_name"]]
if parent_field.link_to_child_resource
return Avo.resource_manager.get_resource_by_model_class(@resource.record.class)
end
end
return @resource unless link_to_child_resource_is_enabled?
return @resource if @resource.record.class.base_class == @resource.record.class
Avo.resource_manager.get_resource_by_model_class(@resource.record.class) || @resource
end |
@MrJoy can you please verify if the issue persists on avo |
@Paul-Bob Sorry for the delay! Will take a look now! |
@Paul-Bob This does indeed appear fixed! TY! |
Great news! |
Context
From here: https://discord.com/channels/740892036978442260/1201874761546735636/1223388242917851176
link_to_child_resource
option should also apply on associations.The text was updated successfully, but these errors were encountered: