Class: CustomCaptcha::CaptchaImagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/custom_captcha/captcha_images_controller.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/custom_captcha/captcha_images_controller.rb', line 15

def change
  @img_id = params[:img_id] || CustomCaptcha::DEFAULTVALUE[:img_id]
  @key_id = params[:key_id] || CustomCaptcha::DEFAULTVALUE[:key_id]
  @key = choice_image_file_path_and_write_session_cache()
  @img_src = show_captcha_image_path(@key)

  respond_to do |format|
    format.js
    format.json { render :json => {@img_id => @img_src, @key_id => @key} }
  end
end

#showObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/custom_captcha/captcha_images_controller.rb', line 5

def show
  @image_file_path = read_image_file_path(params[:key])
  respond_to do |format|
    format.html {
      send_file(@image_file_path, :type => 'image/jpeg', :disposition => 'inline', :filename => 'custom_captcha.jpg')
    }
    format.json { render :json => {:image_file_path => @image_file_path} }
  end
end