Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我设置的初始化程序文件夹中的 devise.rb 文件中:
config.omniauth :facebook, 'APPID', 'APPSECRET',
如何在我的控制器中访问这些值?我需要为其他东西写出 appId,但似乎无法弄清楚这些值。
我觉得你想这样做很奇怪,因为你想保护你的身份和秘密......
但是一种方法是创建一个新文件,我们将其命名为 constants.rb 并放入您的初始化程序文件夹中。像这样:
APPID = "string" APPSECRET = "string"
然后你可以在你的设计文件中使用这些字符串,如下所示:
config.omniauth :facebook, APPID, APPSECRET
您可以在控制器中以相同的方式使用这些常量。另外,不要忘记重新启动您的应用程序。