如何从rails控制台运行初始化程序? [英] how can I run an initializer from the rails console?

查看:234
本文介绍了如何从rails控制台运行初始化程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个初始化文件 config / initializers / linkedin.rb 设置Linkedin gem,以便我的应用程序可以连接到LinkedIn服务并运行查询。我现在正在测试一些新的功能,我想使用控制台这一点。我的问题 - 帮助成为一个新手,而不是很好地理解控制台 - 是我不能访问的变量在 config / initializers / linkedin.rb

I've got an initialization file config/initializers/linkedin.rb that sets up the Linkedin gem so that my app can connect to the LinkedIn service and run queries. I'm now testing out some new features and I want to use the console for this. My problem - asside from being a newb and not understanding the console very well yet - is that I can't access the variables that are initialized in config/initializers/linkedin.rb.

有关如何在控制台中使用应用程序初始化程序的任何想法,以便我不必每次都手动运行?

Any ideas on how to use the application initializers from within the console so that I don't have to run this by hand every time?

谢谢!

推荐答案

尝试:

load "#{Rails.root}/config/initializers/your_file.rb"

这篇关于如何从rails控制台运行初始化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆