Sha256: b2ae716d61dda6a110363541011742e51ff4eca99f77b455b6852d49ff612b36
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
module Rails::ExtJS::Direct::Controller 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 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 params[:id] = @xrequest.id if @xrequest.id.kind_of?(Array) params[:data] = @xrequest.params elsif @xrequest.params.kind_of?(Hash) params[:data] = {} @xrequest.params.each do |k,v| params[:data][k] = v end end end def respond(status, params) @xresponse.status = status @xresponse.message = params[:message] if params[:message] @xresponse.result = params[:result] if params[:result] render :json => @xresponse end def rescue_action(e) if (e.kind_of?(XException)) render :json => XExceptionResponse.new(@xrequest, e) else render :json => XExceptionResponse.new(@xrequest, e) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-extjs-direct-0.0.14 | lib/rails-extjs-direct/mixins/action_controller/direct_controller.rb |