Flash Builder 4 に HTTPService があり、次のように定義されています。
<s:HTTPService id="getUserDetails" url="http://localhost:3000/users/getDetails" method="GET"/>
次のように呼び出されます。
getUserDetails.send({'user[username]': calleeInput.text});
これはネットワーク モニターのスクリーンショットで、パラメーターが正しく送信されていることを示しています (「kirsty」です)。
代替テキスト http://img87.imageshack.us/img87/7513/screenshot20100430at548.png
接続先の Ruby on Rails メソッドは次のとおりです。
def getDetails
@user = User.find_by_username(:username)
render :xml => @user
end
実行すると、コンソールに次のエラー出力が表示されます。
UsersController#list の処理 (2010-04-30 17:48:03 の 127.0.0.1 の場合) [GET] User Load (1.1ms) SELECT * FROM "users" 30ms で完了 (ビュー: 16、DB: 1) | 200 OK [ http://localhost/users/list]
処理 UsersController#getDetails (2010-04-30 17:48:13 の 127.0.0.1 の場合) [GET] パラメータ: {"user"=>{"username"=>"kirsty"}}
User Load (0.3ms) SELECT * FROM "ユーザー" WHERE ("ユーザー"."ユーザー名" = '--- :ユーザー名') LIMIT 1ActionView::MissingTemplate (ビュー パス app/views にテンプレート users/getDetails.erb がありません):
app/controllers/users_controller.rb:36:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb: 65:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in each' / usr/local/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'getDetails'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:inrun'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:instart'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:instart'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:instart'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:inレスキュー/レイアウトのレンダリング (internal_server_error)
Ruby on Rails メソッドの getDetails の不適切なコードが原因でエラーが発生しているのかどうかはわかりません。私は RoR を初めて使用しますが、すべてのメソッドにビューが必要であるとどこかで読んだことを覚えていると思います。Flex 4 アプリに情報を取得するためにこのメソッドを使用していますが、それでもビューを作成する必要がありますか? それがエラーの原因ですか?どんな助けでも大歓迎です、私はこれで数日間立ち往生しています! ありがとう。
編集:
Toby Hede の提案に従って、HTTPService を次のように変更し、.xml を追加しました。
<s:HTTPService id="getUserDetails" url="http://localhost:3000/users/getDetails.xml" method="GET"/>
今、私は次のエラーが発生しています:
Processing ApplicationController#index (for 127.0.0.1 at 2010-04-30 23:32:29) [GET]
Parameters: {"user"=>{"username"=>"kirsty"}}
ActionController::RoutingError (No route matches "/users/getDetails.xml" with {:method=>:get}):
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendering rescues/layout (not_found)