Failure to display entities with ActiveStorage attachments

Hello !
I have run accross a weird error lately :
I cannot display the collections containing an attachement attribute :

On the backend side, the call to the corresponding forest controller raises the following :

➜     ActiveStorage::Blob Load (1.2ms)  SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2  [["id", 33], ["LIMIT", 1]]
➜   [2022-10-17 12:55:27] Forest 🌳🌳🌳  Records Index error: uninitialized constant ForestLiana::UserSpace::ActiveStorageAttachmentSerializer
➜   Did you mean?  ForestLiana::UserSpace::ActiveStorageVariantrecordSerializer
➜   /usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/inflector/methods.rb:288:in `const_get'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/inflector/methods.rb:288:in `block in constantize'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/inflector/methods.rb:284:in `each'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/inflector/methods.rb:284:in `inject'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/inflector/methods.rb:284:in `constantize'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:251:in `find_serializer_class'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:262:in `find_serializer'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:132:in `block in relationships'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:111:in `each'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:111:in `relationships'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:434:in `block in serialize_primary'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:205:in `instrument'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:407:in `serialize_primary'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:453:in `block in serialize_primary_multi'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:453:in `map'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:453:in `serialize_primary_multi'
➜   	/usr/local/bundle/gems/forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb:331:in `serialize'
➜   	/usr/local/bundle/gems/forest_liana-7.4.5/app/controllers/forest_liana/application_controller.rb:44:in `serialize_models'
➜   	/usr/local/bundle/gems/forest_liana-7.4.5/app/controllers/forest_liana/resources_controller.rb:244:in `render_jsonapi'
➜   	/usr/local/bundle/gems/forest_liana-7.4.5/app/controllers/forest_liana/resources_controller.rb:36:in `block (2 levels) in index'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
➜   	/usr/local/bundle/gems/forest_liana-7.4.5/app/controllers/forest_liana/resources_controller.rb:35:in `index'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/abstract_controller/base.rb:228:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/rendering.rb:30:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
➜   	/usr/local/bundle/gems/actiontext-6.1.4.4/lib/action_text/rendering.rb:20:in `with_renderer'
➜   	/usr/local/bundle/gems/actiontext-6.1.4.4/lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:126:in `instance_exec'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:137:in `run_callbacks'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/abstract_controller/callbacks.rb:41:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/rescue.rb:22:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:203:in `block in instrument'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/notifications.rb:203:in `instrument'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
➜   	/usr/local/bundle/gems/activerecord-6.1.4.4/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/abstract_controller/base.rb:165:in `process'
➜   	/usr/local/bundle/gems/actionview-6.1.4.4/lib/action_view/rendering.rb:39:in `process'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal.rb:190:in `dispatch'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_controller/metal.rb:238:in `block in action'
➜   	/usr/local/bundle/gems/forest_liana-7.4.5/app/controllers/forest_liana/router.rb:40:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/mapper.rb:49:in `serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:50:in `block in serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `each'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/route_set.rb:842:in `call'
➜   	/usr/local/bundle/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/engine.rb:539:in `call'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/railtie.rb:207:in `public_send'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/railtie.rb:207:in `method_missing'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/mapper.rb:49:in `serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:50:in `block in serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `each'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/journey/router.rb:32:in `serve'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/routing/route_set.rb:842:in `call'
➜   	/usr/local/bundle/gems/warden-jwt_auth-0.6.0/lib/warden/jwt_auth/middleware/token_dispatcher.rb:20:in `call'
➜   	/usr/local/bundle/gems/warden-jwt_auth-0.6.0/lib/warden/jwt_auth/middleware/revocation_manager.rb:21:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:244:in `call'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar/middleware/rack/builder.rb:16:in `block in call_with_rollbar'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar.rb:145:in `scoped'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar/middleware/rack/builder.rb:14:in `call_with_rollbar'
➜   	/usr/local/bundle/gems/warden-jwt_auth-0.6.0/lib/warden/jwt_auth/middleware.rb:22:in `call'
➜   	/usr/local/bundle/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'
➜   	/usr/local/bundle/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'
➜   	/usr/local/bundle/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/conditional_get.rb:27:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/cookies.rb:689:in `call'
➜   	/usr/local/bundle/gems/activerecord-6.1.4.4/lib/active_record/migration.rb:601:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:98:in `run_callbacks'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/executor.rb:14:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar/middleware/rails/rollbar.rb:25:in `block in call'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar.rb:145:in `scoped'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
➜   	/usr/local/bundle/gems/rollbar-3.3.0/lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
➜   	/usr/local/bundle/gems/web-console-4.2.0/lib/web_console/middleware.rb:132:in `call_app'
➜   	/usr/local/bundle/gems/web-console-4.2.0/lib/web_console/middleware.rb:19:in `block in call'
➜   	/usr/local/bundle/gems/web-console-4.2.0/lib/web_console/middleware.rb:17:in `catch'
➜   	/usr/local/bundle/gems/web-console-4.2.0/lib/web_console/middleware.rb:17:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:37:in `call_app'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:26:in `block in call'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:99:in `block in tagged'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:37:in `tagged'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/tagged_logging.rb:99:in `tagged'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/rack/logger.rb:26:in `call'
➜   	/usr/local/bundle/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
➜   	/usr/local/bundle/gems/request_store-1.5.1/lib/request_store/middleware.rb:19:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/request_id.rb:26:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
➜   	/usr/local/bundle/gems/activesupport-6.1.4.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/executor.rb:14:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/static.rb:24:in `call'
➜   	/usr/local/bundle/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
➜   	/usr/local/bundle/gems/actionpack-6.1.4.4/lib/action_dispatch/middleware/host_authorization.rb:119:in `call'
➜   	/usr/local/bundle/gems/rack-mini-profiler-2.3.3/lib/mini_profiler/profiler.rb:393:in `call'
➜   	/usr/local/bundle/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
➜   	/usr/local/bundle/gems/webpacker-5.4.3/lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
➜   	/usr/local/bundle/gems/rack-proxy-0.7.2/lib/rack/proxy.rb:67:in `call'
➜   	/usr/local/bundle/gems/railties-6.1.4.4/lib/rails/engine.rb:539:in `call'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/configuration.rb:249:in `call'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/request.rb:77:in `block in handle_request'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/request.rb:76:in `handle_request'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/server.rb:447:in `process_client'
➜   	/usr/local/bundle/gems/puma-5.5.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
➜   Completed 500 Internal Server Error in 191ms (ActiveRecord: 20.3ms | Allocations: 55519)

The weirdest part is that it worked before (I already had other collections with attachments) but it occured when I added the attributes on a model. I have rollback my code to the previous change, but it keeps failing on the development environement with the same error (when trying to display the models that already had an attachment.) My remote environement is working well with the same code that I have locally.

Regarding Gem versions, the relevant packages are the following :

  • activestorage (= 6.1.4.4)
  • rails (6.1.4.4)
  • forest_liana (7.4.5)
    forestadmin-jsonapi-serializers (>= 0.14.0)
    forestadmin-jsonapi-serializers (2.0.0.pre.beta.2)

Hello @AugustinBarbe,

After rollbacking your previous changes on the model, have you restart your server ?

Hello !
Yes, I also made sure I had the same .forestadmin.json file on both environments

1 Like

Hello @AugustinBarbe

Could you share the model that has the issue ?

Could you also run the following command :
rails forest:send_apimap
Do you see any changes into the .forestadmin-schema.json file ?

Hello matthv !

Here’s the definition of the model that is failing :

class Document < ApplicationRecord
  belongs_to :attachable, polymorphic: true
  validates_presence_of :kind
  has_one_attached :pdf
  has_paper_trail

This was before the changes I added (and before my local environement broke).

The changes were the following (located on a different model) :

class Enterprise < ApplicationRecord
+  has_one_attached :logo, service: :assets
+  has_one_attached :cover, service: :assets

(I added other attachments with a different service than the default one). Those changes triggered the error, and rollbacking did not fix the development environment

When running the provided command, I receive the following :

 {
     all the contentent of .forestadmin.json 
}
= Apimap Received - nothing changed

And it results in no differences in the .forestadmin.json

I can’t reproduce it on my end.

Did you add a custom serializer or a controller in the lib/forest_liana folder.
If so, could you share it :pray: ?

I have no custom serializers for the forest part, only custom collections for other entities (only defining smart actions)
I suspect some changes in librairies, but I can’t figure what changed (the only reference of the error message I found was in this issue [+] Collections - Forest doesn't support ActiveStorage Β· Issue #253 Β· ForestAdmin/forest-rails Β· GitHub ).
I run the application on docker is it’s any relevant

I’m sorry I still can’t reproduce the bug on my side.
Do you have a sample code that you can send me so that I can investigate?

Unfortunatly I cannot provide more than that I have already…
What are the versions of forest_liana and forestadmin-jsonapi-serializer and active-support do you have on your side ?

I digged a bit into forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer.rb, the class name returned for the attachment object by the find_serializer is ForestLiana::UserSpace::ActiveStorageAttachmentSerializer which does not seem to exists in the library.

I assume strongly that something is messed up on my local environment as the exact same code (and schema definition) is deployed on 3 remote environments ( we have a develop, staging and production that have all the same version deployed as the one on my local environment)

Unfortunately I have used the same versions of gems as you and everything works for me.

Have you tried updating our gem to the latest version.

Hello matthv

I upgraded to the forest_liana 7.7 gem, with no success…
For more context, here is the part of .forestadmin-schema.json related to the collection failing

{
    "name": "Document",
    "icon": null,
    "is_read_only": false,
    "is_searchable": true,
    "is_virtual": false,
    "only_for_relationships": false,
    "pagination_type": "page",
    "fields": [{
      "field": "attachable_id",
      "type": "Number",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    }, {
      "field": "attachable_type",
      "type": "String",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    }, {
      "field": "created_at",
      "type": "Date",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    }, {
      "field": "date",
      "type": "Dateonly",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    },{
      "field": "id",
      "type": "Number",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    }, {
      "field": "kind",
      "type": "Enum",
      "default_value": null,
      "enums": [
        "id_proof",
        "marriage_contract",
        "pacs_proof",
        "pacs_dissolution_proof",
        "divorce_proof",
        "pay_slip",
        "premium_proof",
        "employment_contract",
        "last_amendment_to_the_employment_contract",
        "decree_of_tenure",
        "employer_certificate_of_end_of_trial_period",
        "proof_of_address",
        "property_tax",
        "accommodation_certificate",
        "proof_of_address_of_the_host",
        "id_proof_of_the_host",
        "rent_receipt",
        "rental_lease_covering_the_last_2_years",
        "certificate_of_ownership_real_estate",
        "accepted_offer",
        "notice_of_assessment",
        "draft_of_assessment",
        "bank_statement",
        "annual_cost_statement",
        "family_record_book",
        "expense_proof",
        "savings_proof",
        "revenue_proof",
        "loan_proof",
        "loan_offer",
        "definitive_amortization_table",
        "quote_for_works",
        "energy_performance_diagnostic",
        "notarized_certificate",
        "reservation_contract",
        "quotes_from_selected_companies",
        "quotes_for_companies",
        "project_management_contract",
        "signed_plan",
        "construction_contract",
        "building_permit",
        "sale_agreement",
        "dependent_allowance_proof",
        "balance_sheet",
        "company_status",
        "company_identification",
        "rental_lease_real_estate",
        "rental_income_statement",
        "rental_value_certificate",
        "turnover_certificate",
        "allowance_proof",
        "leasing_proof"
      ],
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": true,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": [{
        "message": null,
        "type": "is present"
      }]
    }, {
      "field": "pdf_attachment",
      "type": "Number",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": "ActiveStorage__Attachment.id",
      "inverse_of": "record",
      "relationship": "HasOne",
      "widget": null,
      "validations": []
    }, {
      "field": "pdf_blob",
      "type": "Number",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": "ActiveStorage__Blob.id",
      "inverse_of": null,
      "relationship": "HasOne",
      "widget": null,
      "validations": []
    }, {
      "field": "updated_at",
      "type": "Date",
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": true,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": null,
      "inverse_of": null,
      "widget": null,
      "validations": []
    }, {
      "field": "versions",
      "type": ["Number"],
      "default_value": null,
      "enums": null,
      "integration": null,
      "is_filterable": false,
      "is_read_only": false,
      "is_required": false,
      "is_sortable": true,
      "is_virtual": false,
      "reference": "PaperTrail__Version.id",
      "inverse_of": null,
      "relationship": "HasMany",
      "widget": null,
      "validations": []
    }],
    "segments": [],
    "actions": []
  },

By any chance, is it possible for you to provide the class that should be returned by the function
forestadmin-jsonapi-serializers-2.0.0.pre.beta.2/lib/jsonapi-serializers/serializer for an activestorage object ?

Regards

We detected a manipulation on the models that prevented forest liana from detecting the models properly

By letting forest liana use ActiveRecord correctly the problem has been solved.

Pro tips the agent uses the list of models via :
ActiveRecord::Base.descendants

3 Likes

To add some context :
I was overriding the class ActiveStorage::Attachment in an initializer :

./config/initializers/role_active_storage.rb

# frozen_string_literal: true

require 'active_storage/attachment'

class ActiveStorage::Attachment
   before_save :configure_service

   def configure_service
      ...
   end
end

One of the consequences is that the class is not listed anymore by ActiveRecord::Base.descendants

Thanks a lot for the help, I’ll figure another way to manage the configuration

2 Likes