Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ruby on rails

What is ActionText in Ruby On Rails?

Faraz Karim

ActionText overview

ActionText is a new inclusion in the rails framework version 6.0, and it enables the creation and storage of rich text content in your rails applications. This means that now features like changing the font and format of text and embedding images and hyperlinks can be done directly in the ruby on rails framework.


As its front-end, ActionText uses the trix- a rich text editor- that provides the user with a WYSIWYGWhat You See Is What You Get interface. For the user, this makes designing the user interface simple. This is because there is a real-time graphical representation of the changes you make while it takes care of producing the HTML required.


Any files that you need can be uploaded to cloud platforms of your choosing through the incorporated Active Storage in ActiveText. It allows you to upload your files/attachments to a cloud storage service like Google Cloud or Microsoft Azure and links them to Active Record objects which we can use to interact with those uploads.

Trix makes the process of uploading very simple with it just requiring the user to drag and drop the required attachments from their local directory to the editor.


Use the following steps to use ActionText in your project:

Step 1

In order to use ActionText the first step is to install it using the following terminal command

bin/rails action_text:install

Step 2

Now you need to include trix and ActionText in your application.js file

// application.js

Step 3

Import the trix stylesheet in the actiontext.scss file

// actiontext.scss
@import "trix/dist/trix";

Step 4

Now, import this actiontext.scss file in your application.scss stylesheet pack:

// application.scss
@import "./actiontext.scss";

With that you are now ready to use ActionText in your Rails project.

Click here to see how you can create a whole project using ActionText.


ruby on rails


Faraz Karim
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring