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

Hi,

I'm using the current TinyMCE plugin for rails (V. 3.2.0.2-1). 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, e.g.

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.

Thanks, Howard

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.

http://github.com/kete/tiny_mce/tree/master/lib/tiny_mce.rb#L6

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” tiny_mce_init(edit_small_options) elsif params[:action] == “edit_big” tiny_mce_init(edit_big_options) else tiny_mce_init # use whatever options specified in the controller end

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

end

Hope this helps.

Regards Kieran

Thank you, that will be helpful.

Howard