GreyCat
GreyCat

Reputation: 17114

Rails: configurable extensible modular application

I'd like to use Rails to build an extensible modular application that can be configured to match one's requirements.

Let me explain what I understand under "extensible" and "modular". For example, let's say I'm working on a blog application engine and I have a model named BlogEntry that contains, well, what a simple blog entry normally contains - title and content. Let's assume I want this application to be able to run in 2 modes:

My goals are:

Thus, if one doesn't want any complex functionality, application stays pretty simple and basic. If one wants extras, application can be extended with several plugins and thus it doesn't end up a huge one-app-that-does-everything bloatware.

In fact, such pluggable functionality exists in virtually any major high-level web development platform, for example, MediaWiki, Moodle, WordPress, etc.

Searching for "modular rails" so far yielded:

I bet there are zillions of ways to achieve what I'm talking about. What would be the best one? Where can I see a good example of such modular application?

Upvotes: 3

Views: 455

Answers (1)

jrochkind
jrochkind

Reputation: 23337

I think Rails Engines is indeed what you want.

I have contributed to several applications that are delivered as Engines to accomplish basically what you describe. Here's one of them which is mainly developed by me: http://github.com/team-umlaut/umlaut

It's not always entirely straightforward, there are a bunch of places where you need to make decisions about how you are going to set things up, and Rails documentation or obvious conventions don't neccesarily guide you. I agree that the (very limited) Engines documentation doesn't neccesarily lead you down this path. But Engines are sufficient to do what needs be doing. Also give you enough rope to hang yourself and over-complicate things.

I would recommend creating an Engine skeleton with rails plugin new name_of_engine --full -- but not --mountable. I think --mountable is over-complication without benefit for this particular kind of engine use case. (Others might disagree; yeah back to that thing about choices and best practices not always being clear for this case).

Rails plugins are basically deprecated; the only kinds of plugins currently supported are plugins-as-gems -- of which an Engine is the most powerful kind (that can do the most kinds of interactions with Rails), which you will want for this kind of thing.

And I agree with you on why app templates are not sufficient here -- although you might want to supply an app template to create an app with your engine in the gemfile to it and any neccesary local stubs generated in the local app. I did that in the latest version of umlaut, but didn't until recently, it's not strictly necessary and I would leave it until after you have at least a basic proof of concept.

Rails doesn't neccesarily encourage this, but it is possible and works out with enough work, and I agree with you is appropriate for certain things.

Upvotes: 1

Related Questions