Modules In Ruby On Rails
I am building a CMS using Ruby on Rails to teach myself the framework. One thing I am trying to work out and can't find resources for is how to build it in a modular format (By this I don't mean Ruby modules, but like the style of Zend Frameword Modules)
so for example:
App : Admin : Controllers
: Views
: Models
: Pages : Controllers
: Views
: Models
: Localisation : Controllers
: Views
: Models
Now I know that there may be a different way to achieve this, but I guess my specific aims are for easy separation of different parts and easy drop in/out, so for example a localisation module could be dropped in to achieve specific extra functionality for localisation etc.
Edit:
I am not trying to build this in the 开发者_运维技巧same way as ZF, however I am assuming there is some way to organise sections of the site. I am trying to work out what RoRs answer to this kind of 'problem' is. I am just using ZF as an example.
My best bet would be to use Rails Engines. They are built to be drop-in modules including views, controllers and models. Basically a way to include a Rails-application into another.
Trying to build an application in one framework the way another framework does it defeats the purpose. It is a nice inclination to want to do that but you are doing yourself no favors by doing so. Rather you should apply your experience to learn how RoR really works, what it's conventions are and then adjust your thinking and approach to solving the problems at hand accordingly.
精彩评论