如何使用 Rails 3 正确安装 ambethia/recaptcha
我已完成以下步骤:
添加到 gemfile:
gem "recaptcha"
添加到 config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'MyKeyHere'
config.private_key = 'MyKeyHere'
end
添加到视图:
= raw recaptcha_tags
Ran: 捆绑安装
...然后重新启动服务器。结果呢?
undefined local variable or method `recaptcha_tags' for #<#<Class:0x1053baaa0>:0x1053b69c8>
I have done the following steps:
Added to gemfile:
gem "recaptcha"
Added to config/initializers/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'MyKeyHere'
config.private_key = 'MyKeyHere'
end
Added to view:
= raw recaptcha_tags
Ran:
bundle install
...then restarted server. The result?
undefined local variable or method `recaptcha_tags' for #<#<Class:0x1053baaa0>:0x1053b69c8>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
The gem 的 README 说,在 Rails 2 中(是的,我知道你在 3 中 - 只是稍等一下 :D),包括以下行来 require gem:
这里需要注意的重要一点是 Rails 本质上应该最终运行
require 'recaptcha/rails'
的指令。您当前的 Gemfile 没有指定这一点,因此它很可能只加载到 gem 的核心类中,而不是特定于 Rails 的搭配中。尝试:
The gem's README says to, in Rails 2 (yes, I know you're in 3—just a minute :D), include the following line to require the gem:
The important bit to note here is the instruction that Rails should essentially end up running
require 'recaptcha/rails'
. Your current Gemfile doesn't have that specified, so it may very well only be loading in the gem's core classes, not the Rails-specific tie-ins.Try:
将以下 gem 添加到您的 gemfile 中。
Add the following gem into your gemfile.