我有一个ruby on rails项目,包括脚手架,视图,布局,模型等。 我还有一些独立的ruby(.rb)文件,我希望在我的上述项目中包含这些文件。 是否可以通过将这些方法放在某处并从控制器中调用它们来简单地调用这些rb文件中定义的这些方法?
如果没有,我怎么去添加它们?
任何帮助将非常感谢,谢谢
I have a ruby on rails project with scaffolding , views, layouts, models and such. I also have some standalone ruby (.rb) files which i would like to include in my afforementioned project. Is it possible to simply call these methods defined in these rb files by placing them somewhere and calling them from the controller or so?
If not, how can i go about and add them?
Any assistance would be highly appreciated thanks
最满意答案
将代码放在lib文件夹中,然后在config/initializers创建一个新的初始化文件,并需要你想要的文件。
Place your code in the lib folder, then create a new initializer file in config/initializers and require the files u want.
更多推荐
rb,ruby,文件,project,files,电脑培训,计算机培训,IT培训"/> <meta name="desc
发布评论