# Terminal
rails 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.rb
class Article < ApplicationRecord
has_rich_text :content
end
# controllers/articles_controller.rb
def article_params
params.require(:article).permit(:name, :content)
end
# _form.html.erb
<div class="field">
<%= form.label :content %>
<%= form.rich_text_area :content %>
</div>
# 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") %>