mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ruby on Rails
app | ||
bin | ||
db/migrate | ||
lib | ||
test | ||
.gitattributes | ||
.gitignore | ||
.ruby-version | ||
actiontext.gemspec | ||
Gemfile | ||
Gemfile.lock | ||
LICENSE | ||
package.json | ||
Rakefile | ||
README.md | ||
yarn.lock |
Action Text
🤸♂️💰📝
Installing
Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.
-
Install the gem:
# Gemfile gem "activetext", github: "basecamp/activetext", require: "action_text" gem "mini_magick" # for Active Storage variants
-
Install the npm package:
// package.json "dependencies": { "activetext": "basecamp/activetext" }
$ yarn install
// app/javascript/packs/application.js import "activetext"
-
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_field
s:<%# app/views/messages/_form.html.erb %> <%= form_with(model: message) do |form| %> … <div class="field"> <%= form.label :content %> <%= form.rich_text_field :content %> </div> … <% end %>