开发者

How to make a global function for rails 3?

开发者 https://www.devze.com 2023-02-27 03:23 出处:网络
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/applicat

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

精彩评论

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