Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do can I implement Modularization in a Rails App?

Breaking a large rails app into smaller apps?

Modularizing Rails applications

Best practice for structuring a 'large' Rails app

I have a quick question on modularization in a large Ruby on Rails App.

Setup:

I am building a core app that stores information about people. I also have several 'modules' that use that information in very different ways. (e.g. one could display information about the people, another could figure out connections and commonalities between them, etc).

The question:

How do I modularize this app efficiently?

Potential Answers:

Since the modules share models and views with the core app (and eachother) it makes sense for me to combine them into one app. However, as the app grows this will obviously lead to problems. This to me suggests either Namespacing the controllers and models "How to organize controller in moderately large Rails application?" or using engines "Modularizing Rails applications".

Since the modules are in active development it is very helpful to use rails generators on them, which seems to make using Engines a pain in the butt. It also seems that while engines are fully supported from a Rails point of view, they still seem rather hacky with regard to lack of generator support and database migrations. Does anyone have experience with developing engines successfully? It seems like engines would be a great solution if you had a working app and wanted to port it into a plugin (i.e. copy paste code) but if you are actively developing it (changing models etc) it would be difficult.

The last thing I have seen around is using multiple apps and one database. This way seems like a royal pain with migrations and keeping models straight etc etc. But I thought I would get thoughts on that as well.

like image 394
user856988 Avatar asked Jul 21 '11 23:07

user856988


1 Answers

Rails engines seem to be the correct solution for you. I have used engines when I worked with Refinery CMS, which is built on top of Rails Engines.

The following are some nice links which talks about Rails Engines:

http://www.themodestrubyist.com/2010/03/01/rails-3-plugins---part-1---the-big-picture/

http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/

http://www.themodestrubyist.com/2010/03/16/rails-3-plugins---part-3---rake-tasks-generators-initializers-oh-my/

http://www.themodestrubyist.com/2010/03/22/rails-3-plugins---part-4---more-on-generators/

like image 67
leenasn Avatar answered Oct 29 '22 01:10

leenasn