mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
1.1 KiB
1.1 KiB
Action Text
🤸♂️💰📝
Installing
Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.
-
Install the gem:
# Gemfile gem "actiontext", github: "basecamp/actiontext", require: "action_text" gem "image_processing", "~> 1.2" # for Active Storage variants
-
Install the npm package (with a local reference to this checked out repository):
$ yarn add file:../actiontext
// app/javascript/packs/application.js import "actiontext"
-
Migrate the database
./bin/rails action_text:install ./bin/rails db:migrate
-
Declare text columns as Action Text attributes:
# app/models/message.rb class Message < ActiveRecord::Base has_rich_text :content end
-
Replace form
text_area
s withrich_text_area
s:<%# app/views/messages/_form.html.erb %> <%= form_with(model: message) do |form| %> … <div class="field"> <%= form.label :content %> <%= form.rich_text_area :content %> </div> … <% end %>