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

has_one field broken for derived class #3692

Open
felixwatts opened this issue Feb 25, 2025 · 1 comment
Open

has_one field broken for derived class #3692

felixwatts opened this issue Feb 25, 2025 · 1 comment
Labels
Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution.

Comments

@felixwatts
Copy link

Describe the bug

A has_one field presented on the edit page of a model that is of a child type of the type of the page contains an "Attach" button that when clicked crashes the server.

The "Attach" button links to path

/admin/resources/<derived type name>/<model slug>/<field name>/new

The server crashes while rendering that URL.

It should link to

/admin/resources/<super type name>/<model slug>/<field name>/new

which is handled correctly.

For example:

class Animal
    has_one: nose
end

class Dog < Animal end

class Avo::Resources::Animal < Avo::BaseResource
    def fields
        field :nose as: :has_one
    end
end

On the edit page for a Dog, on the nose field click Attach a nose

Actual: server crashes
Expected: server doesn't crash

@Paul-Bob
Copy link
Contributor

Hi @felixwatts,

I've attempted to reproduce this behavior in our dummy app but haven’t been able to replicate the issue.

Could you please provide a minimal reproduction repository along with the full crash backtrace?

The attached link dynamically references the current resource. For example:

  • If you're on the Avo::Resources::Animal resource, it links to /admin/resources/animals/<model slug>/nose/new.
  • If you're on the Avo::Resources::Dog resource, it links to /admin/resources/dogs/<model slug>/nose/new.

This behavior is expected, but it should not result in a crash.

@Paul-Bob Paul-Bob added the Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution.
Projects
Status: No status
Development

No branches or pull requests

2 participants