#167 Using Action Text in a Rails 5.2 Application

Summary

With Rails 6.0 is around the corner, Action Text has been merged into the Rails repository. However, it can still be used on a Rails 5.2 application while we wait for its official release.
rails view wysiwyg 7:28

Summary

Terminalrails new template --webpack
rails action_text:install
rails g scaffold article new
rails db:migrate
brew install imagemagick vips
Gemfile# gem 'actiontext', github: 'rails/actiontext', branch: 'archive', require: 'action_text'
gem 'actiontext', github: 'kobaltz/actiontext', branch: 'archive', require: 'action_text'
gem 'image_processing'
models/article.rbclass Article < ApplicationRecord
  has_rich_text :content
end
controllers/articles_controller.rbdef article_params
  params.require(:article).permit(:name, :content)
end
_form.html.erb<div class="field">
  <%= form.label :content %>
  <%= form.rich_text_area :content %>
</div>
layouts/application.html.erb<%= javascript_pack_tag 'application' %>
show.html.erb<h1><%= @article.name %></h1>
<p><%= @article.content %></p>
views/active_storage/blobs/_blob.html.erb<%= image_tag blob.representation(resize: local_assigns[:in_gallery] ? "800x600" : "1024x768") %>
jamessral said 6 months ago on Using Action Text in a Rails 5.2 Application :

This will be pretty cool when Rails 6 lands! Looks really easy to use.

Jan Krupa said 4 months ago on Using Action Text in a Rails 5.2 Application :

I'm currently trying this out, but I run into some error.

When I want to save a content, which contains some image, it raises an error
Field 'blob_id' doesn't have a default value

Without an image, it works fine.

For now, I'm using https://github.com/kylefox/trix/ which works fine and it's simple. But images are saved within the same model.
I suppose I'll wait until rails 6 will be out. (currently using 5.2.2.1)

kobaltz PRO said 4 months ago on Using Action Text in a Rails 5.2 Application :

There could be a configuration issue with the Active Storage. https://www.driftingruby.com/episodes/in-depth-look-into-activestorage is a good episode on the setup and usage of ActiveStorage. Also, try to create a new 5.2.2.1 application and minimally add in the Action Text with Active Storage. See if you run into the same issues so you can at least determine where the issue is.

Jan Krupa said 4 months ago on Using Action Text in a Rails 5.2 Application :

I have still no idea why this does not work. Again i came up with same problem.
I'll try it tomorrow from scratch and I let you know if something different will came up.
Thanks for a help.

Jan Krupa said 4 months ago on Using Action Text in a Rails 5.2 Application :

I create a new application now with SQLite and it works. But updating articles with inserted images from the web are impossible.

I've created a repository with docker-compose. At the end of README is a tutorial on how to run the application and problem description.

I hope I get this run with MySQL, I'll let you know if I do some progress. Sorry for spamming.

bjelline said 2 months ago on Using Action Text in a Rails 5.2 Application :

To get this running on my rails5 app I also had to run

rails action_text:install

it gives you the first two migrations seen in the example code here ,
and runs

yarn add https://github.com/kobaltz/actiontext from "."

bjelline said 2 months ago on Using Action Text in a Rails 5.2 Application :

and i had to add

import "trix/dist/trix.css";

to app/javascript/packs/application.js

Login to Comment