Ruby on Rails October 13, 2020

How to add rich text to your Rails app using Action Text and Trix

Tim Jones @Tjones4413

Hey IH Rails-ers!

I'm currently working on DinoSaaS - I'm building open-source MVP's in Rails along with step-by-step tutorials.

I wrote this 6-step tutorial on how to add rich text to your Rails app.

I'd looked into open-source rich text editors in the past, and this was far easier than I expected it to be:

  1. Step 1 - Install Active Storage and Action Text
  2. Step 2 - Add rich text field to model
  3. Step 3 - permit rich text field as a param in controller
  4. Step 4 - Add rich_text_area to model form
  5. Step 5 - Render rich text in show view
  6. Step 6 - Install image_processing gem to be able to process images.

Should take <10 minutes from start to finish.

Let me know what you think of the linked tutorial and if you have any ideas for what you'd like to see next!

  1. 1

    The tricky part starts when you want to use ActiveStorage in production - gotta connect AWS S3 ;)

  2. 1

    I will not recommend Trix if you care about SEO.

    1. 1

      That's interesting; why do you say that? Is it Trix in general or all Rich Text?

      For my use case, I was only using it for an internal bug tracking app where SEO would not be a concern.

      1. 3

        No p tag. Trix uses div for paragraph
        Images are inside figure instead of img tag
        No support for tables.
        H2 and below not supported out of the box?

        1. 1

          Very good point about actually...
          Let's say: for all non-SEO-sensitive cases, Trix is the go-to Rails approach :)

  3. 1

    This comment was deleted 3 months ago.

Recommended Posts