The perfect choice ,tested on my new application using rails 5.2.3 .
please not action text require ruby 2.5.3 up.
first : Add webpacker
You can either add Webpacker during setup of a new Rails 5.1+ application using new --webpack option:
Available Rails 5.1+
rails new myapp --webpack
Or add it to your Gemfile:
Gemfile
gem 'webpacker', '~> 4.x'
OR if you prefer to use master
gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
yarn add https://github.com/rails/webpacker.git
Now add Actiontext to your gem file with image magic:
gem'actiontext',github:'kobaltz/actiontext',branch:'archive',require:'action_text'
gem 'image_processing'
Finally, run the following to install Webpacker:
bundle
bundle exec rails webpacker:install
rails action_text:install
rails db:migrate
brew install imagemagick vips
add this to your view/layout/application in the head section
#layouts/application.html.erb
<%= javascript_pack_tag 'application' %>
In your model , it may be an article or what ever in your model
class Article < ApplicationRecord
has_rich_text :content
end
in your controller
#controllers/articles_controller.rb
def article_params
params.require(:article).permit(:name, :content)
end
in your form
#_form.html.erb
<div class="field">
<%= form.label :content %>
<%= form.rich_text_area :content %>
</div>
finaly to display the content in your view;
<h1><%= @article.name %></h1>
<p><%= @article.content %></p>
Optional: To fix "unmet peer dependency" warnings,
yarn upgrade
you can watch the full video here:
https://www.driftingruby.com/episodes/using-action-text-in-a-rails-5-2-application