【问题标题】:How can I get ambethia's captcha plugin to work in rails 3?如何让 ambethia 的验证码插件在 rails 3 中工作?
【发布时间】:2010-06-11 21:39:58
【问题描述】:

我已经在我的 rails 3 应用程序中安装了 ambethia's captcha plugin 作为插件。当我将<%= recaptcha_tags %> 放在我的视图中时,它会在页面上打印:

<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=my_key&error=expression"></script> <noscript> <iframe src="http://api.recaptcha.net/noscript?k=my_other_key" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript> 

有没有办法可以在 rails 3 中完成这项工作?如有任何帮助,我将不胜感激。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-plugins captcha ruby-on-rails-3


    【解决方案1】:
    <%=raw recaptcha_tags %>
    

    【讨论】:

      【解决方案2】:

      您已经接受了答案,但是,我将它与 Devise 一起使用,不需要使用 raw - 是的,我在 Rails 3 上:

      app/views/users/registrations/new.html.erb

      <h2>Sign up</h2>
      
      <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
        <%= devise_error_messages! %>
      
        <p><%= f.label :email %><br />
        <%= f.text_field :email %></p>
      
        <p><%= f.label :password %><br />
        <%= f.password_field :password %></p>
      
        <p><%= f.label :password_confirmation %><br />
        <%= f.password_field :password_confirmation %></p>
      
        <p><%= recaptcha_tags %></p>
      
        <p><%= f.submit "Sign up" %></p>
      <% end %>
      
      <%= render :partial => "devise/shared/links" %>
      

      其余代码在一篇文章中:http://www.communityguides.eu/articles/10

      【讨论】:

        猜你喜欢
        • 2012-01-29
        • 1970-01-01
        • 1970-01-01
        • 2014-05-02
        • 2013-07-15
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 2011-07-15
        相关资源
        最近更新 更多