How To Use Action Text

By: Apurva Karankar Category: Ruby on Rails, Web Development Technologies: Ruby on Rails

Action Text

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.

Installation

1. rails action_text:install

Configuration

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: —

2. require(“@rails/actiontext”)

Scaffolding

1. rails generate scaffold Blog title:string

2. rails db:migrate

  • In blog.rb, add this:

1. has_rich_text :body

  • In blogs_controller.rb, permit :body parameter like this:

def blog_params

params.require(:blog).permit(:title, :body)

end

  • In app/views/blogs/_form.html.erb, add this:

<%= form.label :body %>

<%= form.rich_text_area :body %>

  • In app/views/blogs/show.html.erb, add this:

<%= @blog.body %>

Screenshots:-

Happy Blogging!

Originally published at https://www.cryptextechnologies.com.

--

--

--

Cryptex specializes in developing open source web applications and software solutions across all domains and verticals using Ruby on Rails (ROR) technology

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is Video Blackout Management and How can OTT Players Use it?

Avoiding “Headline stress disorder” using IBM Watson and Node-Red

Kubernetes deployment strategy using Azure Devops

Bookmark this if you are new to Python (especially if you self-learn Python)

How to build a Spotify Playlist Slackbot with Serverless Cloud

Dicee App | My second app in Flutter!

Creating a Modular Powerup System

Need of Apache Spark

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cryptex Technologies

Cryptex Technologies

Cryptex specializes in developing open source web applications and software solutions across all domains and verticals using Ruby on Rails (ROR) technology

More from Medium

Integrating Stripe’s Product API Into Your Rails API

Convention over Configurations in Rails

Manage Bundler indirect dependencies versions

Public Rails API- Generating Documentation