7c4e70ea0b | ||
---|---|---|
app | ||
bin | ||
lib | ||
test | ||
.gitattributes | ||
.gitignore | ||
.ruby-version | ||
Gemfile | ||
Gemfile.lock | ||
LICENSE | ||
README.md | ||
Rakefile | ||
activetext.gemspec | ||
package.json | ||
yarn.lock |
README.md
Active Text
🤸♂️💰📝
Installing
Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.
-
Install the gem:
# Gemfile gem "activetext", github: "basecamp/activetext", require: "active_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 Active Text attributes:
# app/models/message.rb class Message < ActiveRecord::Base active_text_attribute :content end
-
Replace form
text_area
s withactive_text_field
s:<%# app/views/messages/_form.html.erb %> <%= form_with(model: message) do |form| %> … <div class="field"> <%= form.label :content %> <%= form.active_text_field :content %> </div> … <% end %>