#167 Using Action Text in a Rails 5.2 Application


With Rails 6.0 is around the corner, Action Text has been merged into the Rails repository. However, it can still be used on a Rails 5.2 application while we wait for its official release.
rails view wysiwyg 7:28


Terminalrails new template --webpack
rails action_text:install
rails g scaffold article new
rails db:migrate
brew install imagemagick vips
Gemfile# gem 'actiontext', github: 'rails/actiontext', branch: 'archive', require: 'action_text'
gem 'actiontext', github: 'kobaltz/actiontext', branch: 'archive', require: 'action_text'
gem 'image_processing'
models/article.rbclass Article < ApplicationRecord
  has_rich_text :content
controllers/articles_controller.rbdef article_params
  params.require(:article).permit(:name, :content)
_form.html.erb<div class="field">
  <%= form.label :content %>
  <%= form.rich_text_area :content %>
layouts/application.html.erb<%= javascript_pack_tag 'application' %>
show.html.erb<h1><%= @article.name %></h1>
<p><%= @article.content %></p>
views/active_storage/blobs/_blob.html.erb<%= image_tag blob.representation(resize: local_assigns[:in_gallery] ? "800x600" : "1024x768") %>
jamessral said about 1 month ago:

This will be pretty cool when Rails 6 lands! Looks really easy to use.

Login to Comment