views:

56

answers:

1

Thanks to some great help on SO, I managed to get a WYSIWYG editor with Paperclip integration working for my app: http://stackoverflow.com/questions/2277348/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?

+1  A: 

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?

Gordon Isnor
That was exactly it! You sir, are a genius :) I guess the error condition was thrown by the "create" action, not the "new" action. I never would have thought to look there... fantastic!
Ganesh Shankar