Search code examples
ruby-on-railstinymcewysiwyg

WYSIWYG editor disappears on validation error


Thanks to some great help on SO, I managed to get a WYSIWYG editor with Paperclip integration working for my app: WYSIWYG image uploads in Rails App

I'm seeing some interesting behaviour where my WYSIWYG editor disappears if there is a validation error.

The editor includes are defined in application.html.haml and look like this:

= javascript_include_tiny_mce_if_used
= tiny_mce if using_tiny_mce?

The editor itself is called by assigning my textarea (which is called Description) a class of this:

= f.text_area :description, :class => "mceEditor"

All this works fine. When a validation error happens however, the WYSIWYG editor disappears... I've done some investigating with Firebug and found that the "error page" doesn't have the TinyMCE includes in it's HEAD.

I thought that all my views would inherit from application.html... Is this not the case for error pages? How do I ensure the includes are correctly processed even under error conditions?


Solution

  • I think @uses_tiny_mce needs to be set to true for the tiny mce helpers to get invoked. The create/update actions may not be invoking tiny mce in your case, but the new/edit actions are, which would explain the varying results?