# Tiny mce - different options for different actions in same controller?

**URL:** <https://www.ruby-forum.com/t/tiny-mce-different-options-for-different-actions-in-same-controller/151680>\
**Category:** Rails\
**Created:** [October 24, 2008, 11:37am UTC](https://www.ruby-forum.com/t/tiny-mce-different-options-for-different-actions-in-same-controller/151680 "2008-10-24T11:37:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hading](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f08c70/32.png) [@hading](https://www.ruby-forum.com/u/hading)\
**Post date:** [October 24, 2008, 11:37am UTC](https://www.ruby-forum.com/t/tiny-mce-different-options-for-different-actions-in-same-controller/151680/1 "2008-10-24T11:37:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hading](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f08c70/32.png) [@hading](https://www.ruby-forum.com/u/hading)\
**Post date:** [October 24, 2008, 11:57am UTC](https://www.ruby-forum.com/t/tiny-mce-different-options-for-different-actions-in-same-controller/151680/2 "2008-10-24T11:57:26Z")

</div>

Hello Howard,

I currently maintain the plugin at [GitHub - kete/tiny\_mce: A Ruby on Rails plugin (pre-Rails 3.1) that allows easy implementation of the TinyMCE editor into your applications.](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.

> <https://github.com/kete/tiny_mce/blob/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

---

<div class="post-metadata">

**Author:** ![hading](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f08c70/32.png) [@hading](https://www.ruby-forum.com/u/hading)\
**Post date:** [October 24, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/tiny-mce-different-options-for-different-actions-in-same-controller/151680/3 "2008-10-24T14:43:03Z")

</div>

Thank you, that will be helpful.

Howard
