Module: Rails::ExtJS::Direct::Controller
- Defined in:
- lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb
Defined Under Namespace
Modules: Helper
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb', line 3 def self.included(base) base.class_eval do cattr_accessor :extjs_direct_actions before_filter :extjs_direct_prepare_request # include the Helper @see helpers/direct_controller_helper.rb helper Helper def self.direct_actions(*actions) unless actions.empty? self.extjs_direct_actions = actions.collect {|a| a.kind_of?(Hash) ? a : {:name => a, :len => 1}} else self.extjs_direct_actions end end end end |
Instance Method Details
#extjs_direct_prepare_request ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb', line 21 def extjs_direct_prepare_request #TODO just populate params with the XRequest data. @xrequest = XRequest.new(params) @xresponse = XResponse.new(@xrequest) token = params["authenticity_token"] || nil params.each_key do |k| params.delete(k) end params["authenticity_token"] = token if token if @xrequest.params.kind_of?(Integer) || @xrequest.params.kind_of?(Array) params[:id] = @xrequest.params elsif @xrequest.params.kind_of?(Hash) @xrequest.params.each do |k,v| params[k] = v end end end |
#rescue_action(e) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb', line 52 def rescue_action(e) if (e.kind_of?(XException)) render :json => XExceptionResponse.new(@xrequest, e) else render :json => XExceptionResponse.new(@xrequest, e) end end |
#respond(status, params) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb', line 44 def respond(status, params) @xresponse.status = status @xresponse. = params[:message] if params[:message] @xresponse.result = params[:result] if params[:result] render :json => @xresponse end |