rails engines 用法

  engines 可以将app中的modle controller view 都放在plugin中,和rails设计初衷不一致,DHH一度比较反对engines。rails的解决方案使用generator。而generator都是放在app下,这样一堆代码都放在app下,也不是很好。相比generator,engines还是有优点的,在rails2.3 它又重新归来(听说django设计是使用mini_app)。
  缺点:
  Rails Engines allow you to package up some of a Rails app (controllers, models, views, routes, libs) and put them in a plugin that can be included into a new Rails app, thereby giving it the functionality you had in the engine. That sounds good, but what about the downsides of using an engine? Well, you can’t override or extend any of the functionality from the engine in your main application. You can hack at the plugin, but now you’ve made it difficult to update. So what do you do if you want to add or alter a method to a controller or model? What do you do if you want to change the look and feel of a view? You have to copy everything into your main application. Boo!

Rails Engines also don’t allow you to package up migrations, assets, plugins, initializers, etc… All the fun stuff that you’ve come to know and love about a Rails application.

  1 install plugin engines:script/plugin install http://svn.rails-engines.org/plugins/engines
  其中controller,view helper 中的方法可以override。详细的见rails-engines.org.
  2  script/generate plugin comment
  3 在vender/plugin 下讲app db  public copy在comment/下,降你的route,或要copy的东东写成脚本,为了下次在多个项目中使用。
  4 具体的看engines源码和readme
 
从bd71x得知 还有一种方式warp drive(http://www.metabates.com/2009/10/07/introducing-warp-drive-for-rails/)

你可能感兴趣的:(django,SVN,脚本,UP,Rails)