Module: Motr::Controller::Helpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/motr/controller/helpers.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#generate_ajax_headers ⇒ Object
Generates additional header information for ajax requests, to allow more flexibility in handling responses.
Instance Method Details
#generate_ajax_headers ⇒ Object
Generates additional header information for ajax requests, to allow more flexibility in handling responses. It simply creates a X-Response-Meta header in the response which contains a json object representing the requested controller and action name, as well as any user defined metadata set with add_response_meta
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/motr/controller/helpers.rb', line 23 def generate_ajax_headers #:nodoc: return true unless response.content_type.to_s.match(/javascript/i) response_params = request.filtered_parameters.dup controller_name = response_params.delete('controller').to_s.underscore action_name = response_params.delete('action').to_s = self.class. = case when Symbol then send() when Proc then .call else end = { :pathinfo => "#{controller_name}##{action_name}", :meta => } response.header['X-Response-Meta'] = .to_json end |