Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building an extension framework for a Rails app

I'm starting research on what I'd need in order to build a user-level plugin system (like Wordpress plugins) for a Rails app, so I'd appreciate some general pointers/advice. By user-level plugin I mean a package a user can extract into a folder and have it show up on an admin interface, allowing them to add some extra configuration and then activate it.

What is the best way to go about doing this? Is there any other opensource project that does this already? What does Rails itself already offer for programmer-level plugins that could be leveraged? Any Rails plugins that could help me with this?

A plugin would have to be able to:

  • run its own migrations (with this? it's undocumented)
  • have access to my models (plugins already do)
  • have entry points for adding content to views (can be done with content_for and yield)
  • replace entire views or partials (how?)
  • provide its own admin and user-facing views (how?)
  • create its own routes (or maybe just announce its presence and let me create the routes for it, to avoid plugins stepping on each other's toes)

Anything else I'm missing?

Also, is there a way to limit which tables/actions the plugin has access to concerning migrations and models, and also limit their access to routes (maybe letting them include, but not remove routes)?

P.S.: I'll try to keep this updated, compiling stuff I figure out and relevant answers so as to have a sort of guide for others.

like image 717
agentofuser Avatar asked Apr 03 '10 02:04

agentofuser


2 Answers

You might want to check out mephisto, it's a blogging software built with ruby on rails and has add-on plugin support. Not sure if it works how you are thinking of, but might give you some good insights. The source can be found on GitHub.

like image 164
Corey Avatar answered Oct 17 '22 03:10

Corey


You should look at deface gem. It allows to customize rails views, adding content via hooks and replacing whole views/partials. Spree is using this gem so you can look also at spree. Beside views they also have other solutions for customizing application so you can find more answers to your questions.

like image 28
Michał Młoźniak Avatar answered Oct 17 '22 03:10

Michał Młoźniak