Permalink
Browse files

Minor fix to get working with rails 3.

  • Loading branch information...
1 parent c33cbab commit 8018c9342b87d63cb566ad9045ed37cadc6ea0b6 @christocracy christocracy committed Feb 6, 2010
Showing with 12 additions and 9 deletions.
  1. +11 −8 lib/rack/remoting_provider.rb
  2. +1 −1 lib/xresponse.rb
@@ -1,8 +1,3 @@
-begin
- require 'json'
-rescue LoadError => load_error
- raise "Error loading 'json' library. Please type 'sudo gem install json' and try again."
-end
class Rails::ExtJS::Direct::RemotingProvider
def initialize(app, rpath)
@@ -24,9 +19,17 @@ def render
end
def call(env)
+
+
if env["PATH_INFO"].match("^"+@router_path)
output = []
- parse(env["action_controller.request.request_parameters"]).each do |req|
+
+ # Rails3 changed where request params are located:
+ # Rails 2.3.x: action_controller.request.request_parameters
+ # Rails 3.x: action_dispatch.request.request_parameters
+ #
+ params_key = env["action_controller.request.request_parameters"] ? "action_controller.request.request_parameters" : "action_dispatch.request.request_parameters"
+ parse(env[params_key]).each do |req|
# have to dup the env for each request
request_env = env.dup
@@ -39,7 +42,7 @@ def call(env)
request_env["REQUEST_URI"] = "/#{controller}/#{action}"
# set request params
- request_env["action_controller.request.request_parameters"] = req
+ request_env[params_key] = req
# call the app!
# TODO Implement begin/rescue to catch XExceptions
@@ -54,7 +57,7 @@ def call(env)
res = "[" + res + "]" if output.length > 1
# return response
- [200, {"Content-Type" => "text/html"}, res]
+ [200, {"Content-Type" => "text/html"}, [res]]
else
@app.call(env)
end
View
@@ -26,7 +26,7 @@ def to_h
{:tid => @tid, :status => @status, :type => @type, :message => @message, :result => @result, :errors => @errors}
end
- def to_json
+ def to_json(*params)
self.to_h.to_json
end
end

0 comments on commit 8018c93

Please sign in to comment.