module RmagickCaptcha module ControllerAdditions module ClassMethods def download_rmagick_captcha(*symbols) symbols.each do |sym| define_method("#{sym}") do key = session[params[:id]] # Get current captcha key and send back image = key.nil? ? "" : ::RmagickCaptcha::RmagickBackend.get_captcha_image(key) send_data(image, :filename => "captcha.png", :type => "image/png", :disposition => 'inline') end end end end end end