Ajith Kumar
Ajith Kumar

Reputation: 168

How to add tinymce-rails gem in activeadmin?

I am using active admin gem in my Rails application.In that, I have a resources article and user and I need to use TinyMCE-rails in the article. It is possible to add if possible how?

Upvotes: 2

Views: 1137

Answers (2)

DRAD
DRAD

Reputation: 147

I realize this is a bit late but in hopes that this may help someone else in the future - TinyMCE is active and the tinymce-rails gem is actively maintained (latest release as of writing is just under 2 months old). Getting this to work in ActiveAdmin is not too hard, the github page and TinyMCE and ActiveAdmin for Rails post tell you most of what you need but here is what I did:

  1. add the tinymce-rails gem - bundle install
  2. add TinyMCE assets by adding //= require tinymce to application.js
  3. register tinymce.js in active_admin.js and initialize it by adding the following to your active_admin.js file (this was the missing key for me):
...
//= require tinymce
...
// initialize tinymce
$(document).ready(function() {
  tinyMCE.init({
     selector: 'textarea.editor',
     browsser_spellcheck: true,
     menubar: 'edit view insert format tools table help',
     plugins: 'code image link lists media preview table'
   });
});

To use it in a form:

...
f.input :description, input_html: {rows: 4, class: 'editor'}
...

Hope this helps someone down the road.

Upvotes: 1

Piers C
Piers C

Reputation: 2978

There are a number of WYSISWG editor plugins for ActiveAdmin. The TinyMCE plugin has not been updated for a while so I don't know its status. A couple of the others are more current.

Upvotes: 1

Related Questions