0

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?

Andrey Belykh
  • 2,578
  • 4
  • 32
  • 46
Ganesh Shankar
  • 4,826
  • 8
  • 43
  • 56
  • strange ... when using erb the validation page definitely uses the standard layout. No idea what haml does in this case. – Toby Hede Feb 23 '10 at 04:20

1 Answers1

1

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
  • 2,065
  • 1
  • 19
  • 32
  • 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 Feb 23 '10 at 06:00