Rails ships with a rich text editor, called ActionText. RailsAdmin can make use of it in two ways.
Follow the official documentation to configure ActionText.
$ rails action_text:installclass Message < ApplicationRecord
has_rich_text :content
endAt this point RailsAdmin will use the CDN-delivered ActionText assets and it lacks some features like uploading attachments. You'll see a warning like ActionText assets should be loaded statically... in your browser console as well. To eliminate the warning and get the full features, please proceed to the next section.
Alternatively, if you don't need the full features you can choose to suppress the warning by:
field :action_text_field do
warn_dynamic_load false
endThe method you should take varies depending on how your application is configured to deliver RailsAdmin assets.
RailsAdmin will automatically load required assets. No setup is needed.
Install the ActionText NPM package.
$ yarn add @rails/actiontextAdd following contents to files within your Rails application.
config/importmap.rails_admin.rb (be sure to use the latest version for each package!)
pin '@rails/actioncable/src', to: 'https://ga.jspm.io/npm:@rails/actioncable@7.0.4/src/index.js'
pin '@rails/actiontext', to: 'https://ga.jspm.io/npm:@rails/actiontext@7.0.4-1/app/assets/javascripts/actiontext.js'
pin '@rails/activestorage', to: 'https://ga.jspm.io/npm:@rails/activestorage@7.0.4/app/assets/javascripts/activestorage.esm.js'
pin 'trix', to: 'https://ga.jspm.io/npm:trix@2.0.0-beta.0/dist/trix.js'app/javascript/rails_admin.js
import "trix";
import "@rails/actiontext";app/assets/stylesheets/rails_admin.scss
@import "trix/dist/trix";Install the ActionText NPM package.
$ yarn add @rails/actiontextAdd following contents to files within your Rails application.
app/javascript/packs/rails_admin.js or app/javascript/rails_admin.js
import "trix";
import "@rails/actiontext";app/javascript/stylesheets/rails_admin.scss or app/assets/stylesheets/rails_admin.scss
@import "trix/dist/trix";