🚧❌ EDITED ActionText is now fully released in Rails 6 don't follow this guide that was written for the preview version
You might have seen the video of DHH about ActionText upcoming feature in Rails 6. This is a step by step guide for creating the exact same example as in the video.
⚠️ If like me you never ran an edge version of Rails before and wonder how to do it then this is for you
git clone https://github.com/rails/rails.git cd rails bundle install
We will want to create a new app within the same directory and using the locally installed Rails generator
#move out of rails folder first cd .. #create the app with the local rails generator and the edge flag to use GH master branch rails/railties/exe/rails new yabe --edge cd yabe
⚠️ remember to always use the local rails command:
You should now have the rails startup screen showing
Rails version: 6.0.0.alpha 🎉🎉
# Gemfile gem "actiontext", github: "rails/actiontext", require: "action_text" gem "image_processing", "~> 1.2" # for Active Storage variants
bundle install bin/rails action_text:install bin/rails db:migrate
bin/rails g scaffold post title:string bin/rails db:migrate
# app/models/post.rb class Post < ApplicationRecord has_rich_text :content end
Active Text brings a polymorphic model under the hood for managing
<%= form.rich_text_area :content %> : rich_text_area is the new content type to display Trix
<%#app/views/posts/_form.html.erb %> <%= form_with(model: post) do |form| %> … <div class="field"> <%= form.label :content %> <%= form.rich_text_area :content %> </div> … <% end %>
<%= @post.content %>
def post_params params.require(:post).permit(:title, :content) end
- My first take out was to use an edge version of Rails.
- With regards to ActiveText I am impressed with how simple it is to now add rich text editing in a Rails app.
- I love Trix don't get me wrong but I would like to have a layer of abstraction to potentially have other front-end solution for the Editor.