{"record":{"id":"7c7071a6ec96d276","repo":"railsadminteam/rails_admin","slug":"actiontext-assets-should-be-loaded-statically-fol","errorCode":null,"errorMessage":"ActionText assets should be loaded statically. Follow instructions in https://github.com/railsadminteam/rails_admin/wiki/ActionText","messagePattern":"ActionText assets should be loaded statically\\. Follow instructions in https://github\\.com/railsadminteam/rails_admin/wiki/ActionText","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/rails_admin/widgets.js","lineNumber":493,"sourceCode":"              '\" rel=\"stylesheet\" media=\"all\" type=\"text/css\">'\n          );\n          $.getScript(\n            options[\"jspath\"],\n            (function (_this) {\n              return function (script, textStatus, jqXHR) {\n                return goFroalaWysiwygs(array);\n              };\n            })(this)\n          );\n        } else {\n          goFroalaWysiwygs(array);\n        }\n      }\n      return content.find(\"trix-editor\").each(function () {\n        if (!window.Trix) {\n          options = $(this).data(\"options\");\n          if (options.warn_dynamic_load) {\n            console.warn(\n              \"ActionText assets should be loaded statically. Follow instructions in https://github.com/railsadminteam/rails_admin/wiki/ActionText\"\n            );\n          }\n          $(\"head\").append(\n            '<link href=\"' +\n              options[\"csspath\"] +\n              '\" rel=\"stylesheet\" media=\"all\" type=\"text/css\">'\n          );\n          return $.getScript(options[\"jspath\"]);\n        }\n      });\n    }\n  });\n})(jQuery);\n","sourceCodeStart":475,"sourceCodeEnd":508,"githubUrl":"https://github.com/railsadminteam/rails_admin/blob/0690a5e62f8d99bc00495a3754f5189b23124387/src/rails_admin/widgets.js#L475-L508","documentation":"This is a browser console.warn emitted by RailsAdmin's widgets.js, not a Ruby exception. When a form renders a trix-editor (an ActionText/rich-text field) and window.Trix is undefined, RailsAdmin falls back to dynamically injecting the ActionText stylesheet (csspath) and loading its JS via $.getScript(jspath) — see app/views/rails_admin/main/_form_action_text.html.erb. If the field's warn_dynamic_load option is true (the default, from lib/rails_admin/config/fields/types/action_text.rb:25), it prints this warning telling you to load ActionText assets statically instead.","triggerScenarios":"A model has has_rich_text :body (ActionText attribute), the admin edit form renders it, and the JavaScript bundle loaded by the admin layout does not define window.Trix — i.e. actiontext/trix is not included in application.js or in the pack/esbuild entry the admin uses. warn_dynamic_load defaults true, so the warning fires on every such form load, followed by a runtime <link> injection and $.getScript fetch.","commonSituations":"Rails 6+ app where `require actiontext` was never added to the asset bundle; admin pages served from a different pack or layout that omits ActionText; environments with a strict Content-Security-Policy where the dynamic $.getScript/style injection is blocked or races; CI/system tests that assert on a clean console and fail on the warning.","solutions":["Add ActionText to the bundle the admin actually loads: Sprockets — `//= require trix` and `//= require actiontext` in application.js; webpacker/esbuild — `import '@rails/actiontext'` in the entry point, plus the ActionText stylesheet (`require('@rails/actiontext')` CSS or app/assets/stylesheets/actiontext.css).","Verify statically: reload the admin page and check `typeof window.Trix` in the browser console before the form renders — it must not be 'undefined'.","If dynamic loading is intentional in your setup, silence it per field: `field :body, :action_text do; warn_dynamic_load false; end` — the csspath/jspath injection still happens, only the warning is suppressed.","If you use a CSP, prefer the static bundle: the $.getScript path frequently violates script-src and leaves the editor unstyled."],"exampleFix":"// before: app/javascript/packs/application.js (admin loads this, ActionText missing)\nimport Rails from '@rails/ujs';\n\n// after: load ActionText statically, warning disappears and trix-editor initializes\nimport Rails from '@rails/ujs';\nimport '@rails/actiontext'; // brings in Trix; import its css too\nimport '@rails/actiontext/app/assets/stylesheets/actiontext.css';","handlingStrategy":"validation","validationCode":"// In the admin layout/pack, fail loudly at load time instead of warning at form time\nif (typeof window.Trix === 'undefined') {\n  console.error('ActionText/Trix not bundled — import \"@rails/actiontext\" in the admin JS entry');\n}\n// ESM check at build time (preferred): this line itself guarantees the asset\nimport '@rails/actiontext';","typeGuard":"const trixBundled = () => typeof window.Trix !== 'undefined';\n// guard before relying on trix-editor being initialized\nif (!trixBundled() && options.warn_dynamic_load) {\n  // dynamic csspath/jspath injection path in widgets.js will run — avoid depending on it\n}","tryCatchPattern":null,"preventionTips":["Import @rails/actiontext (and its CSS) in every JS entry the admin layout loads, so window.Trix exists before any admin form renders.","If you keep dynamic loading, set warn_dynamic_load false deliberately and verify your CSP allows the injected script/style.","Add a system spec that visits an edit page for a rich-text model and asserts page.evaluate('typeof window.Trix') is not 'undefined'."],"tags":["rails-admin","actiontext","trix","javascript","asset-pipeline","console-warning"],"backgroundTag":"missing-javascript-asset","analyzedSha":"0690a5e62f8d99bc00495a3754f5189b23124387","analyzedAt":"2026-08-21T18:31:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}