Activity Text permits us to bring rich text content and editing to Rails. This implies we can perform operations like formatting text, inserting pictures, formatting links, adding records, and other editorial feature to a text field.
This is finished by including the Trix editor for the framework. The RichText content produced by the Trix editorial is saved in its own RichText model that is related to any current Active Record model in the application. Every inserted picture or different connections are automatically put away utilizing Active Storage.
1. rails action_text:install
Make sure your app/assets/stylesheets/actiontext.scss contains the following line:
1 . @import “./actiontext.scss”;
And your app/assets/stylesheets/application.scss has the following lines:
1. require(“trix”) — — → (ActionText uses the Trix editor to help create rich content. Trix is a WYSIWYG style editor that updates how a WYSIWYG editor works on the web)
Trix Editor: —
1. rails generate scaffold Blog title:string
2. rails db:migrate
1. has_rich_text :body
<%= form.label :body %>
<%= form.rich_text_area :body %>
<%= @blog.body %>