railsadminteam/rails_admin · warning

ActionText assets should be loaded statically. Follow instru

Error message

ActionText assets should be loaded statically. Follow instructions in https://github.com/railsadminteam/rails_admin/wiki/ActionText

What it means

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.

Source

Thrown at src/rails_admin/widgets.js:493

              '" rel="stylesheet" media="all" type="text/css">'
          );
          $.getScript(
            options["jspath"],
            (function (_this) {
              return function (script, textStatus, jqXHR) {
                return goFroalaWysiwygs(array);
              };
            })(this)
          );
        } else {
          goFroalaWysiwygs(array);
        }
      }
      return content.find("trix-editor").each(function () {
        if (!window.Trix) {
          options = $(this).data("options");
          if (options.warn_dynamic_load) {
            console.warn(
              "ActionText assets should be loaded statically. Follow instructions in https://github.com/railsadminteam/rails_admin/wiki/ActionText"
            );
          }
          $("head").append(
            '<link href="' +
              options["csspath"] +
              '" rel="stylesheet" media="all" type="text/css">'
          );
          return $.getScript(options["jspath"]);
        }
      });
    }
  });
})(jQuery);

View on GitHub (pinned to 0690a5e62f)

Solutions

  1. 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).
  2. Verify statically: reload the admin page and check `typeof window.Trix` in the browser console before the form renders — it must not be 'undefined'.
  3. 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.
  4. If you use a CSP, prefer the static bundle: the $.getScript path frequently violates script-src and leaves the editor unstyled.

Example fix

// before: app/javascript/packs/application.js (admin loads this, ActionText missing)
import Rails from '@rails/ujs';

// after: load ActionText statically, warning disappears and trix-editor initializes
import Rails from '@rails/ujs';
import '@rails/actiontext'; // brings in Trix; import its css too
import '@rails/actiontext/app/assets/stylesheets/actiontext.css';
Defensive patterns

Strategy: validation

Validate before calling

// In the admin layout/pack, fail loudly at load time instead of warning at form time
if (typeof window.Trix === 'undefined') {
  console.error('ActionText/Trix not bundled — import "@rails/actiontext" in the admin JS entry');
}
// ESM check at build time (preferred): this line itself guarantees the asset
import '@rails/actiontext';

Type guard

const trixBundled = () => typeof window.Trix !== 'undefined';
// guard before relying on trix-editor being initialized
if (!trixBundled() && options.warn_dynamic_load) {
  // dynamic csspath/jspath injection path in widgets.js will run — avoid depending on it
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of railsadminteam/rails_admin@0690a5e62f (2026-08-21). Data as JSON: /api/errors/7c7071a6ec96d276. Report an issue: GitHub.