field :body, as: :trix
Trix field renders a WYSIWYG Editor and can be associated with a
text column in the database. The value stored in the database will be the editor's resulting
Trix field is hidden from the
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
Hides the attachment's name from the upload output in the field value.
Hides the attachment size from the upload output in the field value.
Hides the attachment URL from the upload output in the field value.
Enables file attachments.
nil, or a symbol representing the
has_many_attachments key on the model.
You must manually require
image_processing gems in your
# Active Storage makes it simple to upload and reference files
# High-level image processing wrapper for libvips and ImageMagick/GraphicsMagick
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
attachment_key has to have the same name as the model.
class Post < ApplicationRecord
Now, when you upload a file in the Trix field, Avo will create an Active Record attachment.
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