Skip to content

Field: RichTextAreaField

Philip Kocanda edited this page Sep 14, 2019 · 4 revisions

In order to use administrate with ActionText, create a new RichTextAreaField.

Execute generate command.

$ rails g administrate:field rich_text_area

Create app/fields/rich_text_area_field.rb

require "administrate/field/text"

class RichTextAreaField < Administrate::Field::Text
  def to_s
    data
  end
end

Create app/views/fields/rich_text_area_field/_form.html.erb

<div class="field-unit__label">
  <%= f.label field.attribute %>
</div>
<div class="field-unit__field">
  <%= f.rich_text_area(field.attribute) %>
</div>

Create both app/views/fields/rich_text_area_field/_index.html.erb (don't recommend showing this in a collection view) and app/views/fields/rich_text_area_field/_show.html.erb

<%= field.to_s %>

Instructions on getting the JS and CSS included are listed in the Rails 6 & Webpacker wiki.

User Docs

Clone this wiki locally