Sha256: ca5384e281c3cae4f944c32c7445580e71b66f240bc4cee2d0b092728276ab86
Contents?: true
Size: 740 Bytes
Versions: 9
Compression:
Stored size: 740 Bytes
Contents
# coding: utf-8 module RailsCaptcha module Action def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_captcha unless included_modules.include? InstanceMethods include InstanceMethods end before_filter :assign_captcha end end module InstanceMethods private def assign_captcha unless session[:captcha] && RailsCaptcha::Config.exists?(session[:captcha]) files = RailsCaptcha::Config.captchas session[:captcha] = File.basename(files[rand(files.length)], '.jpg') end end def reset_captcha session[:captcha] = nil assign_captcha end end end end
Version data entries
9 entries across 9 versions & 1 rubygems