# Internal plugin architecture, where to start from

**URL:** <https://www.ruby-forum.com/t/internal-plugin-architecture-where-to-start-from/169566>\
**Category:** Rails\
**Created:** [June 5, 2009, 11:01am UTC](https://www.ruby-forum.com/t/internal-plugin-architecture-where-to-start-from/169566 "2009-06-05T11:01:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nutsmuggler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/57b2e6/32.png) [@nutsmuggler](https://www.ruby-forum.com/u/nutsmuggler)\
**Post date:** [June 5, 2009, 11:01am UTC](https://www.ruby-forum.com/t/internal-plugin-architecture-where-to-start-from/169566/1 "2009-06-05T11:01:04Z")

</div>

Hello folks.  
I am refactoring a simple CMS, and looking to implement a simple  
internal plugin architecture.  
I have a MenuItem class. By default, menu items can be, say, ‘article’  
or ‘sitemap’, or ‘newsroll’. I want to implement a hook to which my  
modules can plug, so I will be able to add other tipologies (like  
“catalog”, “gallery” or whatever) through modules, which are aptly  
structured plugins.  
Presently, I have something like this:

`class MenuItem < ActiveRecord::Base
  belongs_to :article
  @tipologies = Array.new
  @tipologies.push("article","sitemap")
  def self.tipologies
    return @tipologies
  end
  def self.addTipology(item)
    @tipologies.push(item)
  end
end`  
I have been able to add an item to @typologies through a plugin, with  
this init.rb

```auto
ActionController::Base.send :include, Tipeadder
```

And this is the main plugin code (obviously I am just sketching here):

`# Tipeadder.rb
module Tipeadder
  MenuItem.addTipology("cane")
  MenuItem.addTipology("gatto")
end`

Yet the type is added only when the app is first loaded, then it gets  
lost.  
I am a also bit lost here. I have been using plugin architectures for  
ages in Wordpress development, but never implemented one, so i am not  
sure I am going the right way.  
Have you go some general advice on the procedure I should follow? Which  
is the best and most ruby-like way to do this?  
Thanks,  
Davide
