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

Hyrax::Forms::CollectionForm.model_class gets set before configuration is read #6869

Open
1 task
ryanfb opened this issue Aug 5, 2024 · 0 comments
Open
1 task

Comments

@ryanfb
Copy link
Contributor

ryanfb commented Aug 5, 2024

Descriptive summary

In Hyrax v5, the default for Hyrax.config.collection_model changed from '::Collection' to 'Hyrax::PcdmCollection' (https://github.com/samvera/hyrax/blob/main/lib/hyrax/configuration.rb#L898). This should be able to be overridden by setting Hyrax.config.collection_model = '::Collection' in a Hyrax initializer. Unfortunately, Hyrax::Forms::CollectionForm.model_class seems to be initialized before configuration takes place (https://github.com/samvera/hyrax/blob/main/app/forms/hyrax/forms/collection_form.rb#L19), causing a default of Hyrax::PcdmCollection to persist in Hyrax::Forms::CollectionForm.model_class when interacting with any CollectionForm.

Steps to reproduce the behavior in User Interface (UI)

  1. Set Hyrax.config.collection_model = '::Collection' in e.g. config/initializers/hyrax.rb
  2. Boot Hyrax app
  3. Hyrax::Forms::CollectionForm.model_class should evaluate to ::Collection, but is instead Hyrax::PcdmCollection

Actual behavior (include screenshots if available)

Upgrading from 4.x to 5.x and expecting old ::Collection behavior to persist results in lots of unexpected broken behavior around Collections.

Acceptance Criteria/Expected Behavior

  • Setting Hyrax.config.collection_model = '::Collection' persists to Hyrax::Forms::CollectionForm.model_class

An easy workaround would be to have an environment variable like HYRAX_COLLECTION_MODEL optionally used for the default before falling back to a hardcoded default. A clean fix would be to defer setting Hyrax::Forms::CollectionForm.model_class until after Rails configuration/initialization has taken place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant