Ruby on Rails
Go to file
David Heinemeier Hansson 491bee6e64 Use rich_text instead of active_text
Just like we use has_many_attachments instead of active_storage_attachements.
2018-04-13 14:10:18 -07:00
app Use rich_text instead of active_text 2018-04-13 14:10:18 -07:00
bin Pull activetext.js into dummy app with webpacker 2018-02-12 10:34:29 -05:00
lib Use rich_text instead of active_text 2018-04-13 14:10:18 -07:00
test Use rich_text instead of active_text 2018-04-13 14:10:18 -07:00
.gitattributes Initial commit 2018-02-07 12:43:36 -06:00
.gitignore Pull activetext.js into dummy app with webpacker 2018-02-12 10:34:29 -05:00
.ruby-version Tests: Add Message scaffolding 2018-02-08 16:02:16 -05:00
Gemfile Add dummy app 2018-02-08 11:01:46 -06:00
Gemfile.lock Dummy: Add mini_magick for variants 2018-02-14 09:45:44 -05:00
LICENSE Initial commit 2018-02-07 12:43:36 -06:00
README.md Use rich_text instead of active_text 2018-04-13 14:10:18 -07:00
Rakefile Add dummy app 2018-02-08 11:01:46 -06:00
activetext.gemspec Dummy: Add mini_magick for variants 2018-02-14 09:45:44 -05:00
package.json Try to please semver theory 2018-04-13 13:54:48 -07:00
yarn.lock Add initial ActiveStorage integration 2018-02-12 15:50:42 -05:00

README.md

Active Text

🤸‍♂️💰📝

Installing

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

  1. Install the gem:

    # Gemfile
    gem "activetext", github: "basecamp/activetext", require: "active_text"
    gem "mini_magick" # for Active Storage variants
    
  2. Install the npm package:

    // package.json
    "dependencies": {
      "activetext": "basecamp/activetext"
    }
    
    $ yarn install
    
    // app/javascript/packs/application.js
    import "activetext"
    
  3. Declare text columns as Active Text attributes:

    # app/models/message.rb
    class Message < ActiveRecord::Base
      has_rich_text :content
    end
    
  4. Replace form text_areas with rich_text_fields:

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