From 43b166ad5115fb72a6edd3e416988b9fb75f5ee3 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 14 Feb 2018 15:44:38 -0500 Subject: Add basic install guide --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 07e2238c34..9c0b8d777b 100644 --- a/README.md +++ b/README.md @@ -1 +1,56 @@ -# activetext +# Active Text + +πŸ€Έβ€β™‚οΈπŸ’°πŸ“ + +## Installing + +Assumes a Rails 5.2+ application with Active Storage and Webpacker installed. + +1. Install the gem: + + ```ruby + # Gemfile + gem "activetext", github: "basecamp/activetext", require: "active_text" + gem "mini_magick" # for Active Storage variants + ``` + +1. Install the npm package: + + ```js + // package.json + "dependencies": { + "activetext": "basecamp/activetext" + } + ``` + + ```sh + $ yarn install + ``` + + ```js + // app/javascript/packs/application.js + import "activetext" + ``` + +1. Declare text columns as Active Text attributes: + + ```ruby + # app/models/message.rb + class Message < ActiveRecord::Base + active_text_attribute :content + end + ``` + +1. Replace form `text_area`s with `active_text_field`s: + + ```erb + <%# app/views/messages/_form.html.erb %> + <%= form_with(model: message) do |form| %> + … +
+ <%= form.label :content %> + <%= form.active_text_field :content %> +
+ … + <% end %> + ``` -- cgit v1.2.3