aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: ca6a395e8e9f43f10337f69f41760cfc5286233e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Action Text

πŸ€Έβ€β™‚οΈπŸ’°πŸ“

## Installing

Assumes a Rails 5.2+ application with Active Storage and Webpacker installed.

1. Install the gem:

    ```ruby
    # Gemfile
    gem "actiontext", github: "basecamp/actiontext", require: "action_text"
    gem "image_processing", "~> 1.2" # for Active Storage variants
    ```
   
1. Install the npm package:

    ```js
    // package.json
    "dependencies": {
      "actiontext": "basecamp/actiontext"
    }
    ```
    
    ```sh
    $ yarn install
    ```
    
    ```js
    // app/javascript/packs/application.js
    import "actiontext"
    ```

1. Migrate the database

   ```
   ./bin/rails action_text:install
   ./bin/rails db:migrate
   ```

1. Declare text columns as Action Text attributes:

    ```ruby
    # app/models/message.rb
    class Message < ActiveRecord::Base
      has_rich_text :content
    end
    ```

1. Replace form `text_area`s with `rich_text_area`s:

    ```erb
    <%# 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 %>
    ```