安装插件:
controller回调
最后要在页面添加
[url=http://github.com/subwindow/negative-captcha]官网[/url]
[url=http://taito.iteye.com/blog/296359]另一个参考如下[/url]
script/plugin install http://code.subwindow.com/negative_captcha
git submodule add git://github.com/subwindow/negative-captcha.git vendor/plugins/negative_captcha
controller回调
before_filter :setup_negative_captcha, :only => [:new, :create]
private
def setup_negative_captcha
@captcha = NegativeCaptcha.new(
:secret => NEGATIVE_CAPTCHA_SECRET, #A secret key entered in environment.rb. 'rake secret' will give you a good one.
:spinner => request.remote_ip,
:fields => [:name, :email, :body], #Whatever fields are in your form
:params => params)
end
最后要在页面添加
<% form_tag comments_path do -%>
<%= negative_captcha(@captcha) %>
<ul class="contact_us">
<li>
<label>Name:</label>
<%= negative_text_field_tag @captcha, :name %>
</li>
<li>
<label>Email:</label>
<%= negative_text_field_tag @captcha, :email %>
</li>
<li>
<label>Your Comment:</label>
<%= negative_text_area_tag @captcha, :body %>
</li>
<li>
<%= submit_tag %>
</li>
</ul>
<% end -%>
[url=http://github.com/subwindow/negative-captcha]官网[/url]
[url=http://taito.iteye.com/blog/296359]另一个参考如下[/url]