Rails 3 环境变量属于哪里?
我对 Ruby on Rails 3 比较陌生,希望将 Ambethia 的 Recaptcha 插件集成到我的应用程序中。
在下面看起来像 Rails 2 文档的内容中,要求将以下内容放入environment.rb中,
ENV['RECAPTCHA_PUBLIC_KEY'] = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
ENV['RECAPTCHA_PRIVATE_KEY'] = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
这与 Rails 3environment.rb 文件的关系到底在哪里,目前如下所示:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Testapp::Application.initialize!
I'm relatively new to Ruby on Rails 3 and hope to integrate Ambethia's Recaptcha plugin into my app.
In following what looks like Rails 2 documentation, it's asked to place the following into environment.rb
ENV['RECAPTCHA_PUBLIC_KEY'] = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
ENV['RECAPTCHA_PRIVATE_KEY'] = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
Where exactly does this go in relation to the Rails 3 environment.rb file, which currently looks like the following:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Testapp::Application.initialize!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在rails 3中,您可以像单例一样使用Rails::Application类,因此您可以直接添加
来访问此数据
,之后您可以通过不再需要ENV数据
。在你的控制器中,一条简单的线就可以工作。
并且在视野中
in rails 3, you can use your Rails::Application class like a singleton so, you can add directly
And after you can access to this data by
No more needed you ENV data.
In your controller a simple line works.
And in view