开发者

Why make a Rails plugin instead of putting code in /lib?

In Rails, what's the difference betw开发者_JAVA技巧een making a plugin and adding modules to the /lib directory?

I see that to effect changes to a plugin, I have to restart the server, but that's the only difference I see. Why would I make a plugin instead of putting a module in /lib?

(sys: Ruby 1.8.7, Rails 2.3.5)


It makes it simpler and more straight forward when you want to distribute your module for other people to use.


By making a standalone plugin you increase the code's reusability, both by yourself and others. It also helps enforce the code's modularity by making sure any app-specific functionality is abstracted out into configuration, callbacks, etc. which makes testing easier. (That's also possible in an in-app library, but more easily enforceable when it's 100% decoupled.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜