TinyMCE and ActiveAdmin for Rails

I meet Rails again and I really like Active Admin. I would like tinyMCE to work with it for use in text areas. However, any instructions that I find are incomplete. For some reason, I think I'm missing something really simple here.

So, for example, I have tinymce-rails installed (3.4.9) and follow the instructions (https://github.com/spohlenz/tinymce-rails). However, here, where I think I failed: I actually initiated tinyMCE. According to the document, I have two options:

  • use helper <% = tinymce%> or ...
  • initialize it as follows tinyMCE.init({ mode: 'textareas', theme: 'advanced' });

I tried adding the latter to my active_admin.js file to no avail.

If anyone could direct me to this, I would be very grateful.

+5
source share
2 answers

I worked on this as follows (outside of the setup described in repo )

In admin / my_class.rb:

ActiveAdmin.register MyClass do
  form do |f|
    f.inputs do 
      f.input :body, :input_html => { :class => "tinymce" }
    end
  end
end

In the / active _admin.rb initializers:

...
config.register_javascript 'tinymce.js'

This is what the tinymce.js script actually got to display in the admin layout.

In javascripts / active_admin.js:

//= require active_admin/base
//= require tinymce

$(document).ready(function() {
  tinyMCE.init({
     mode: 'textareas',
     theme: 'advanced'
   });
});

After performing these actions on this element of the body (text area) there was a fully functioning editor on it.

+13
source

Do your textarea attachments have a 'class' attribute or something that tinyMCE can connect to? Does it work from javascript console (firefox / chrome)? You checked the presence of tinymce.js in the head (source) of your page.

, , tinymce .

<%= f.input :literature_nld, :input_html => { :class => 'tinymce', :size => "80x4" } %>

.

0

All Articles