Skip to content

Instantly share code, notes, and snippets.

@vmcilwain
Created October 18, 2017 17:19
Show Gist options
  • Save vmcilwain/5fd92ba0095685be42efa9911220b6d8 to your computer and use it in GitHub Desktop.
Save vmcilwain/5fd92ba0095685be42efa9911220b6d8 to your computer and use it in GitHub Desktop.
Adding trix editor to a rails form_tag (using haml)
# Given there is a section object and I would like to use trix editor for adding text to the content attribute
# id: is required to tie trix-editor(below to to the hidden input
# name: is required so that you can find it via params in the controller in this case params["trix-editor_section_#{section.id}"]
# content: is for inserting any content that already existed in the content attribute
%input{id: "#{dom_id(section, 'trix-editor')}", name: "#{dom_id(section, 'trix-editor')}", content: "#{section.content}", type: :hidden}
%trix-editor{input: "#{dom_id(section, 'trix-editor')}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment