ruby-on-railsarchitecturesocial-networkingplugin-architectureplug-and-play

How do I have plugin architecture in Ruby on Rails?


I have to built a social networking site on Ruby on Rails. The features in the site may change from time to time; so we will need to add/remove features with ease. Moreover, we may be building another social networking site. Due to these reasons, we are thinking to build a basic framework for social networking sites in RoR with the feature to install or uninstall extensions to the framework.

I worked previously in Joomla! CMS and its architecture for adding/removing extensions is kind of what I am looking at. In a Joomla! installation there is usually an admin side from which you can add/remove/customize extensions.

I am new to RoR and finding it little difficult to decide how to do this. Any help will be appreciated.


Solution

  • UPDATE 2015: this was answered in 2009 a lot has changed

    Plug-ins have been superseded by Gems and Engines For all the information you need on Engines: http://guides.rubyonrails.org/engines.html

    Engines are a fantastic way of building encapsulated and reusable code for your rails apps.

    Original Answer for Reference

    On the development side Rails Engines and/or plugins is probably what you are looking for.

    Rails Engines are small subsets of an application that can be dropped into any of your Rails applications and handle common parts of the application from scratch.

    Say for example your social networking application has a wiki, blog, chatroom etc. You would more than likely want to create a wiki engine, blog engine and chatroom engine.

    Engines allows you to re-use such functionality within different applications so you do not have to repeat yourself.

    Take a look at: http://rails-engines.org/

    Some support for ‘engine’ plugins has been merged into the Rails core codebase in Rails 2.3.

    I would also recommend taking a look at some public projects say on github and see how people have used engines.

    Take a look at some engines:

    Other useful links for reading

    In functionality terms you could still have an admin area that could activate certain features ie. your blog or wiki by allowing users access to such areas with a permissions/roles system.

    If you want to build a CMS which supports some kind of extensions like in Wordpress or Joomla then you will have to either build it and provide guidlines or at least look into how you would upload/install Engines/Plugins from a user perspective.

    Not sure on the security implications of this

    Redmine has put this kind of functionality into their awesome application. You may want to dig around the source code for tips and clues

    Finally Adva_CMS has basically adopted this approach and have created a number of Engines for their CMS application

    HTH