Last Updated: February 25, 2016
·
1.945K
· irio

Remove image upload from activeadmin-wysihtml5

This gem activeadmin-wysihtml5 (available at https://github.com/stefanoverna/activeadmin-wysihtml5) from Stefano Verna gives you a simple way to add a WYSIWYG interface to ActiveAdmin inputs.

But I was needing just the WYSIWYG part, without the image upload feature. In this case, the solution was just not add the image item in the commands list in ActiveAdmin's configuration.

# /app/admin/model_name.rb
ActiveAdmin.register ModelName do
  form do |f|
    f.inputs do
      f.input :content,
        as: :wysihtml5,
        commands: %i(bold italic underline ul ol outdent indent link source),
        blocks:   %i(),
        height:   :large
    end

    f.actions
  end
end

Since activeadmin-wysihtml5 registers a new model - called Asset -, a undesired link was keeped at the top of administration interface. To hide it:

# /app/admin/asset.rb
ActiveAdmin.register Asset do
  menu false
end