Module: Motr::Controller::Helpers::ClassMethods

Defined in:
lib/motr/controller/helpers.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_response_meta(options) ⇒ Object

Adds additional “meta” information to AJAX response headers. By default an additional X-Response-Meta header is added to ajax requests which describes the current controller/action names. Passing additional information to this method adds data to that header.

Examples:

Add a “post_name” meta


class PostsController < ApplicationController
  add_response_meta { :post_name => 'This post is awesome' }
end
* index action run *

'X-Response-Meta' #=> { :pathinfo => 'posts#index', :meta => { :post_name => 'This post is awesome' } }

Parameters:

  • options (Hash, Proc, Symbol)

    Information to be added to the response header. If a hash is used, the data is passed directly. If a symbol is used, it is considered an instance method to be called on the controller. If a proc is used it is evaluated when the data is built. NOTE: Procs/methods are called AFTER actions are run. This way action data can be used.



66
67
68
# File 'lib/motr/controller/helpers.rb', line 66

def add_response_meta(options)
  self. = options
end

#enable_script_events(opts = {}) ⇒ Object

Deprecated.

Use add_response_meta



73
74
75
76
# File 'lib/motr/controller/helpers.rb', line 73

def enable_script_events(opts = {})
  ActiveSupport::Deprecation.warn("enable_script_events is deprecated. Please use the 'add_response_meta helper'")
   = opts
end