thoughtbot / thoughtbot/administrate

Field::Polymorphic in form causing form page to take very long to load

Open
#2,004 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I have a model Review which has a Field::Polymorphic Reviewable.

When I try to access the form page through new/edit, it takes very long to load due to the form loading every instance of a reviewable object.

Is there anyway to prevent the loading of all instance of the polymorphic class?

Alternatively is there a way I can have 'helper attributes' that do not exist in the model, but are used to determine the id of the polymorphic field?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Field::Polymorphic from the form page described in the issue and identify where every reviewable instance is loaded during new/edit. Determine how the field should avoid loading all instances or support helper attributes, then verify that the form remains usable without eagerly loading the full polymorphic collection.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.