avo-hq / avo

Build Ruby on Rails apps 10x faster
https://avohq.io
Other
1.51k stars 242 forks source link

Polymorphic Record is not preselected in Edit view, when using STI and using Avo Advanced gem #3351

Open rctneil opened 2 days ago

rctneil commented 2 days ago

Describe the bug

With Avo Advanced, the Polymorphic field does not prepopulate with the selected record when editing.

Steps to Reproduce

Steps to reproduce the behavior:

Reproduction respository is here: https://github.com/rctneil/avorepro

Must have Avo Advanced to replicate.

  1. Start app
  2. Navigate to Attractions
  3. Click "Daemonen"
  4. Edit "Daemonen"
  5. Change "Type" to "Coaster"
  6. Save "Daemonen"
  7. Click the first "Companyable" (id 6)
  8. Note the "Companyable" field shows as "Daemonen"
  9. Edit the "Companyable"
  10. Note the "Attraction" field is not set. (ie: not prepopulated)

Expected behavior & Actual behavior

When viewing the Edit page of a Companyable, the Attraction field should be populated with the selected Attraction.

Models and resource files

System configuration

Avo version: 3.13.6

Rails version: 7.2.1.1

Ruby version:

License type:

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

Screenshots or screen recordings

Additional context

This occurs ONLY when Avo Advanced is being used. DOES NOT happen when the "Type" of the "Attraction" record is blank or default. Only when set to "Coaster"

Impact

Urgency

Paul-Bob commented 23 hours ago

There seems to be an issue with the searchable: true option on a polymorphic belongs_to field.

Thank you for the reproduction repository and the detailed steps.

If possible don't use searchable: true on the polymorphic belongs_to field until we look deeper into this and fix it.