开发者

How to make a global function for rails 3?

Can somebody pls tell me how to make a function accessible to all, regardless if its a controller, model, h开发者_运维技巧elper, or view will call it. Is there a way to do this?


in your config/application.rb:

Dir.glob("./lib/*.{rb}").each { |file| require file } # require each file from lib directory

then just create .rb file with all you need and put it to your /lib directory

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜