Adminpanel

View the Project on GitHub codn/adminpanel

Special Behavior

Modules

Generators

Module · Wysiwyg Trix Attachments

To add attachments to a wysiwyg field, you need to mount an uploader with the name of the relation’s model and add uploader => :trixfiles to your wysiwyg hash.

Model

mount_uploader :trixfiles

# ...

def self.form_fields
  [
    # ...
    {
      'body' => {
        'type' => 'wysiwyg_field',
        'uploader' => :trixfiles,
        'images' => true,
        'label' => 'Cuerpo',
        'show' => 'false'
      },
    },
  ]
end

text_attachment.rb

module Adminpanel
  class Trixfile < Image
    include Adminpanel::Base
    mount_uploader :file, TextAttachmentUploader

  end
end

Controller

def whitelisted_params
  params.require(:somet).permit(
    # ...
    trixfile_ids: [],
    # ...
  )
end