1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Ruby on Rails
Find a file
David Heinemeier Hansson 531d7dd584 Never mind on allowing blank
More hassle than its worth. Just account for the fact that rich text can be blank instead, but continue to create the record.
2018-09-12 15:51:06 -07:00
app Never mind on allowing blank 2018-09-12 15:51:06 -07:00
bin Pull activetext.js into dummy app with webpacker 2018-02-12 10:34:29 -05:00
db/migrate Never mind on allowing blank 2018-09-12 15:51:06 -07:00
lib Never mind on allowing blank 2018-09-12 15:51:06 -07:00
test Never mind on allowing blank 2018-09-12 15:51:06 -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
actiontext.gemspec Missed a spot 2018-04-13 16:26:19 -07:00
Gemfile Add dummy app 2018-02-08 11:01:46 -06:00
Gemfile.lock Use actiontext references in Gemfile.lock 2018-05-28 17:14:27 +02:00
LICENSE Initial commit 2018-02-07 12:43:36 -06:00
package.json Reference action text for js packaging 2018-05-28 18:07:55 +02:00
Rakefile Rename from Active Text to Action Text 2018-04-13 16:23:04 -07:00
README.md Update instructions to get the local version of actiontext 2018-07-31 15:55:53 -07:00
yarn.lock Add initial ActiveStorage integration 2018-02-12 15:50:42 -05:00

Action Text

🤸‍♂️💰📝

Installing

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

  1. Install the gem:

    # Gemfile
    gem "actiontext", github: "basecamp/actiontext", require: "action_text"
    gem "image_processing", "~> 1.2" # for Active Storage variants
    
  2. Install the npm package (with a local reference to this checked out repository):

    $ yarn add file:../actiontext
    
    // app/javascript/packs/application.js
    import "actiontext"
    
  3. Migrate the database

    ./bin/rails action_text:install
    ./bin/rails db:migrate
    
  4. Declare text columns as Action Text attributes:

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

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