我正在使用带有简单验证码 gem 的 rails 3.0.2 和 ruby 2.0.0。
宝石文件 -
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
看法 -
Verification code:<%= show_simple_captcha :label => "Please type the verification code", :image_style => "simply_green", :object => "foo" %>
但验证码图像未显示在视图中。
每次我在 Rails 控制台中收到此错误时-
2014-05-05 23:38:41 +0530 开始 GET "/simple_captcha?code=d3423b2321c833f8974c50e34528603f111c0d40&time=1399313320" for 127.0.0.1
TypeError(无法将 nil 转换为 Integer)
我也尝试关注此博客,但没有成功。
控制器:-
def contact
if request.post?
@contact = Contact.new(params[:contact])
if @contact.valid_with_captcha?
@contact.save_with_captcha
flash[:title] = "Thank you"
else
flash[:title] = "Sorry"
end
redirect_to contact_us_path
else
@contact = Contact.new
end
end
谢谢