tiny mce - different options for different actions in same controller?


I'm using the current TinyMCE plugin for rails (V. I want
to know if there is a way to use different options for the editor in a
single controller depending on the action invoked. I've tried re-
invoking the uses_tiny_mce declaration in the individual actions,

def my_action
  self.class.uses_tiny_mce :options => {this actions options}

and also using separate uses_tiny_mce declarations at the top
with :only filters to discriminate between the actions, e.g.

uses_tiny_mce :only => [:edit_small], :options => {edit_small options}
uses_tiny_mce :only => [:edit_big], :options => {edit_big_options}

but neither of these approaches seem to work.


Hello Howard,

I currently maintain the plugin at http://github.com/kete/tiny_mce (which looking at the version number appears to be the one you’re using). If thats the one you use, then what you want to do isn’t currently possible via the controller.


As you’ll see in the link above, it sets an instance variable used later in the view helpers. The last declaration of uses_tiny_mce will overwrite that variable.

However, the view helpers can take a different set of options. So you can do something like this in application.html.erb:

if params[:action] == “edit_small”
elsif params[:action] == “edit_big”
tiny_mce_init # use whatever options specified in the controller

Having a look at it now, I see I missed a couple of places for passing those options (for example include_tiny_mce_if_needed(edit_big_options) isn’t possible), so for now (until I get a chance to push some changes), to stop including tiny_mce unnessesarily, wrap the tiny_mce code in an using_tiny_mce? conditional, like so

if using_tiny_mce?

the rest of the application.html.erb code above


Hope this helps.


Thank you, that will be helpful.