Class: Qa::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/qa/application_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cors_allow_origin_header(response) ⇒ Object

Note:

The qa.rb initializer is copied to /config/initializers/qa.rb and can be modified to enable/disable cors headers.

Add cors headers to the passed in http response if cors_headers are enabled. Called by all controller actions to adjust the response.

Parameters:

  • http

    response

See Also:

  • /lib/generators/qa/install/templates/config/initializers/qa/lib/generators/qa/install/templates/config/initializers/qa.rb


24
25
26
# File 'app/controllers/qa/application_controller.rb', line 24

def self.cors_allow_origin_header(response)
  response.headers['Access-Control-Allow-Origin'] = '*' if Qa.config.cors_headers?
end

Instance Method Details

#optionsObject

Process the OPTIONS method for all routes

See Also:

  • definitions in /config/routes.rb


8
9
10
11
12
13
14
15
16
# File 'app/controllers/qa/application_controller.rb', line 8

def options
  unless Qa.config.cors_headers?
    head :not_implemented
    return
  end
  response.headers['Access-Control-Allow-Origin'] = '*'
  response.headers['Access-Control-Allow-Methods'] = 'GET, OPTIONS'
  head :no_content
end