Display polymorphic fields in v9

Feature(s) impacted

Fields displayed on collections using the polymorphic associations

Observed behavior

When using the old major version (8.3.1), polymorphic fields were correctly displayed (field_type, field_id), since we upgraded to v9 (9.3.16) the fields just disappeared and there’s no way to show them (unless using smart fields)

Expected behavior

Display the polymorphic fields (field_id, field_type)

Failure Logs

The polymorphic fields disappeared from the forest schema. I see them back when reverting to v8

Context

  • Project name: Trustpair
  • Team name: Product
  • Environment name: Production
  • Agent technology: rails
  • Agent (forest package) name & version: 9.3.16
  • Database type: postgres
  • Recent changes made on your end if any: upgraded from v8 to v9

Hey :wave:

As mentionned in our documentation, v9 supports polymorphic association using a direct relation (This was the major change of v9, along with the enforced role system).

This means that, indeed, these _type & _id aren’t in your schema anymore.

What is your use-case being needing the _type & _id fields to be present directly instead of the actual polymorphic relation?

Does your v9 schema embed this new polymorphic relation, or it is ignored completely?

If you actively need these those fields, then indeed, Smart Field is the new way to go..

Let me know if that helps :pray:
(Or we can discuss this further during our call if you prefer :+1: )

Hey Jeff,
Thanks for the quick reply. Yes we noticed that those fields aren’t present anymore, but it would still be interesting to see the type, as we believe it provides valuable information to the user.
In our case, we have a company registration polymorphic association, and it would be insightful to know which type of registration it is without actually having to check the DB or even adding the smart field.
The schema is properly reflecting the polymorphic relationships, so it’s working as you expect.

Also, something worth mentioning is that, in case the model class name and the relationship name changes, the type is still displayed in the UI (what we want).


# The registration type is not shown in the collection
class CompanyRegistration < ApplicationRecord
  #  registration_type :string
  belongs_to :registration, inverse_of: :company_registration, polymorphic: true
  # ...
end


# The type IS shown in the collection
class Notification < ApplicationRecord
  #  recipient_type :string           not null
  belongs_to :recipient, polymorphic: true

Hey :wave:

Just to sum up what we discussed, we’re currently discussing this internally in order to provide a way to re-add those field in v9.

We’ll let you know if we find something easily do-able on our end - or if we can provide an easy way to get those fields back.

Sorry for the inconvenience.