# Using a controller to initiate a plugin?

**URL:** <https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337>\
**Category:** Rails\
**Created:** [July 21, 2006, 8:09pm UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337 "2006-07-21T20:09:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [July 21, 2006, 8:09pm UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337/1 "2006-07-21T20:09:46Z")

</div>

Folks I am new so I apologize if I come off as a totaly tool. I am  
finding Rails to be an amazing framework to use and having fun with it.  
I have run into a frustrating snag however with PLUGINS.

I have a plugin installed in: /myapp/vendor/plugins/  
When I run: ruby script/server in /myapp/ my WEBrick starts normally and  
I can access IP:3000. I get the default rails index page.

How do I “enable” the plugin? How do I tell the app to use it? I try to  
access the directories and I just get 404 not founds so obviously I am  
not doing it correctly.

Insight and advice greatly appreciated.

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [July 21, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337/2 "2006-07-21T20:27:00Z")

</div>

Update:  
When I access anything on the server now (index.html) the default rails  
page I get this:

#\<NoMethodError: undefined method `clear!' for Controllers:Module> ["/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:53:in`reset\_application!’",  
“/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:75:in  
`reset_after_dispatch'", "/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:46:in`dispatch’”,  
“/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:117:in  
`handle_dispatch'", "/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in`service’”, “/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'", "/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’”,  
“/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'", "/usr/lib/ruby/1.8/webrick/server.rb:162:in`start\_thread’”,  
“/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'", "/usr/lib/ruby/1.8/webrick/server.rb:92:in`start’”,  
“/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'", "/usr/lib/ruby/1.8/webrick/server.rb:82:in`start’”,  
“/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:69:in  
`dispatch'", "./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59", "/usr/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’”,  
“./script/…/config/…/vendor/rails/activesupport/lib/active\_support/dependencies.rb:147:in  
`require’”,  
“./script/…/config/…/vendor/rails/railties/lib/commands/server.rb:39”,  
“script/server:3”]

I have no idea what this means…

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [July 24, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337/3 "2006-07-24T17:58:17Z")

</div>

Brad wrote:

> Folks I am new so I apologize if I come off as a totaly tool. I am  
> finding Rails to be an amazing framework to use and having fun with it.  
> I have run into a frustrating snag however with PLUGINS.
> 
> I have a plugin installed in: /myapp/vendor/plugins/  
> When I run: ruby script/server in /myapp/ my WEBrick starts normally and  
> I can access IP:3000. I get the default rails index page.
> 
> How do I “enable” the plugin? How do I tell the app to use it? I try to  
> access the directories and I just get 404 not founds so obviously I am  
> not doing it correctly.
> 
> Insight and advice greatly appreciated.

Anyone have any ideas? ☹

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [July 25, 2006, 11:35am UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337/4 "2006-07-25T11:35:19Z")

</div>

Normally, you don’t have to do anything to ‘enable’ a plugin; when  
Rails starts up, the plugin’s init.rb file will be evaluated, and the  
plugin should do anything it needs at that point.

Using a plugin depends from each to the next. Some provide new syntax  
or macro-esque methods that you can use in your controllers or models,  
in which case the plugin will probably do nothing until you make use  
of those features in your code.

Which plugin is it that you’re trying to use?

- james

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [July 24, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/using-a-controller-to-initiate-a-plugin/99337/5 "2006-07-24T18:06:47Z")

</div>

Hey Brad -

each plugin does it’s own thing, and so your question is a little  
too generic.

but you can count on needing a model/controller/view to use the  
plugin. The plugin will be generally activated by the Model - such as

class Machine \< ActiveRecord::Base  
acts\_as\_state\_machine :initial =\> :idle

state :idle  
state :running, :enter =\> Proc.new { |o| o.stop\_timer(‘idle’);  
o.do\_work() }

etc.  
…

This is how I ‘use’ the act\_as\_state\_machine plugin.

see the plugins docs for instructions on how it is specially used.

enjoy the journey!  
Jodi
