Trix ​
field :body, as: :trix
The Trix
field renders a WYSIWYG Editor and can be associated with a string
or text
column in the database. The value stored in the database will be the editor's resulting HTML
content.

Trix field is hidden from the Index
view.
Options ​
-> always_show
By default, the content of the Trix
field is not visible on the Show
view; instead, it's hidden under a Show Content
link that, when clicked, displays the content. You can set Markdown to display the content by setting always_show
to true
.
Default ​
false
Possible values ​
true
, false
-> attchments_disabled
-> hide_attachment_filename
Hides the attachment's name from the upload output in the field value.
Default ​
false
Possible values ​
true
, false
-> hide_attachment_filesize
Hides the attachment size from the upload output in the field value.
Default ​
false
Possible values ​
true
, false
-> hide_attachment_url
Hides the attachment URL from the upload output in the field value.
Default ​
false
Possible values ​
true
, false
-> attachment_key
Enables file attachments.
Default ​
nil
Possible values ​
nil
, or a symbol representing the has_many_attachments
key on the model.
File attachments ​
WARNING
You must manually require activestorage
and image_processing
gems in your Gemfile
.
# Active Storage makes it simple to upload and reference files
gem "activestorage"
# High-level image processing wrapper for libvips and ImageMagick/GraphicsMagick
gem "image_processing"
Trix supports drag-and-drop file attachments. To enable Active Storage integration, you must add the attachment_key
option to your Trix field.
field :body, as: :trix, attachment_key: :trix_attachments
That attachment_key
has to have the same name as the model.
class Post < ApplicationRecord
has_many_attached :trix_attachments
end
Now, when you upload a file in the Trix field, Avo will create an Active Record attachment.
Disable attachments ​
You may want to use Trix only as a text editor and disable the attachments feature. Adding the attachments_disabled
option will hide the attachments button (paperclip icon).
field :body, as: :trix, attachments_disabled: true
Remove attachment attributes ​
By default, Trix will add some meta-data in the editor (filename, filesize, and URL) when adding an attachment. You might not need those to be present in the document. You can hide them using hide_attachment_filename
, hide_attachment_filesize
, and hide_attachment_url
.