Skip to content

has_one field on show page doesn't render Show action, and renders parent record when it shouldnt. #4087

@gee-forr

Description

@gee-forr

Describe the bug

If I have a model (A), that has a has_one assoc to another model (B), the show page for model A renders the has_one for model B with two problems:

  1. Model B does not have a Show action, so there is no way to link to the has_one assoced resource.
  2. Model B renders its parent model as a belongs_to when it shouldn't - as we're already on the parent model's show page. (see screenshot)

Steps to use in the reproduction repository

  • Create a model that has a has_one assoc to another model
  • Specify the field in your model as has_one
  • Go to your model's show page
  • You will see there is no way to go from viewing your parent model to viewing the has_one assoced model.
  • Additionally, the embedded has_one model renders the parent model. This could be omitted for a cleaner and simpler view, as we're already viewing the parent model.

Expected behavior & Actual behavior

  • There should be a way to jump to the has_one assoced model, when on the parent model's show page.
  • An embedded has_one assoc should omit its parent record.

System configuration

Avo version: 3.24.1

Rails version: 8.0.3

Ruby version: 3.3.6

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Image

Additional context

Here's the thread on the Avo discord where this issue was originally discussed.

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions