Action Text provides rich text fields for your applications where you can upload images, @mention users, and create other types of dynamic attachments.
Action Text is installed by default in Jumpstart Pro.
Rich text fields are extremely easy to add. You can use the rich_text
type when generating models and scaffolds and everything will be setup for you.
rails g scaffold Message body:rich_text
You can also add a rich text attribute manually by adding has_rich_text :body
to your model, add the rich_text_area
to your form and permit the attribute in the controller.
Action Text does not require any migrations to add fields, so this is all you need to do.
Check out the GoRails screencast episodes on Action Text and the Action Text Rails Guide for more information on how to use Action Text.
We have preinstalled Action Text for you in Jumpstart Pro and added User mentions so you can easily reference users. By default, it will only search users of the current account. You can modify this to search all users depending on your needs.
Scaffolds have been modified to automatically enable this feature for rich_text_area
fields.
You can add it to your own rich_text_area by simply adding the following Stimulus data attributes:
<%= form.rich_text_area :body, data: { controller: "mentions", mentions_target: "field" } %>
To disable mentions for a field, simply remove the data attributes.