Tag: ruby on rails pluginsvalidation

Gem-idea:当HTTP方法发布,放置或删除时,在before_filter中使用validation码自动保护垃圾邮件

我正在考虑为rails编写一个自动垃圾邮件保护系统(也许我会写一个公共gem)。 我的概念是在application_controller中包含一个辅助方法: class ApplicationController 30.seconds :limit => 50) … end 然后我想在每个控制器中自动包含一个before_filter,如果当前请求是通过post,put或delete-method检查的话。 如果用户的上次发布请求小于:min_time,则应将请求重定向到captcha-input-page(发布的用户数据驻留在隐藏的html字段中)。 # before_filter :check_spam def check_spam if !request.get? && session[:last_manipulation_at] && session[:last_manipulation_at] >= DateTime.now – 30.seconds redirect_to captcha_path # (doesn’t know yet how to handle the post data to # display in hidden fields in the spam-captcha-form) end end 在captcha.haml中 =form_tag -request.params.each do |key, […]