def puts_yellow(heredoc) puts set_color heredoc, :yellow end def puts_green(heredoc) puts set_color heredoc, :green end if !defined?(Webpacker) puts_yellow 'Webpacker was not installed. Adding it now...' gem 'webpacker' rails_command 'webpacker:install' end rails_command 'action_text:install' rails_command 'db:migrate' puts_green <<~HEREDOC Action Text is installed. Read the docs at https://guides.rubyonrails.org/action_text_overview.html # app/models/message.rb class Message < ApplicationRecord has_rich_text :content end # app/views/messages/_form.html.erb <%= form.label :content %> <%= form.rich_text_area :content %> # view <%= @message.content %> # controller class MessagesController < ApplicationController def create message = Message.create! params.require(:message).permit(:title, :content) redirect_to message end end HEREDOC