我试图在没有模型对象的情况下使用ambethia recaptcha,没有运气。有人能给我一个在没有模型对象的方法中使用ambethia recaptcha的例子吗?
例如,我正在编写一种忘记密码的方法。
def forgotten_password
if (params[:email] =~ /\A[a-z]+[0-9]*(_|.|-){1}[a-z]*[0-9]*@{1}[a-z]{3,}.{1}(com|net|org|info|biz|me|edu|gov){1}\z/i).nil?
flash[:warning] = "Invalid email!"
redirect_to(forgotten_password_path)
else
user = Profile.find_by_email(params[:email])
unless verify_recaptcha
flash[:warning] = "Email or captcha is incorrect!"
redirect_to(forgotten_password_path)
else
end
end
端
谢谢。
答案 0 :(得分:0)
嗯,问题是我在忘记的电子邮件表单中使用了一个表。我不确定为什么会导致问题,但确实如此。
答案 1 :(得分:0)
你可以尝试这样吗?
def forgotten_password
if (params[:email] =~ /\A[a-z]+[0-9]*(_|.|-){1}[a-z]*[0-9]*@{1}[a-z]{3,}.{1}(com|net|org|info|biz|me|edu|gov){1}\z/i).nil?
flash[:warning] = "Invalid email!"
redirect_to(forgotten_password_path)
else
user = Profile.find_by_email(params[:email])
if !verify_recaptcha
flash.delete(:recaptcha_error)
flash[:warning] = "Email or captcha is incorrect!"
redirect_to(forgotten_password_path)
else
redirect_to success_path
end
end