我将 JSON 作为 POST 发送到 Heroku 服务器上的 ruby 应用程序(来自 Android 应用程序)。正如帖子标题所说,Heroku 日志输出:
Started GET "/app_session" for 62.40.34.220 at 2013-05-20 22:12:22 +0000
ActionController::RoutingError (No route matches [GET] "/app_session"):
这是安卓请求:
HttpPost httppost = new HttpPost(url.toString());
httppost.setHeader("Content-type", "application/json");
httppost.setHeader("Accept", "application/json");
StringEntity se = new StringEntity(json.toString());
httppost.setEntity(se);
HttpResponse response = httpclient.execute(httppost);
String temp = EntityUtils.toString(response.getEntity());
jsonResponse = new JSONObject(temp);
这是路由文件:
resources :app_session, only: [:create, :destroy]
和rake routes
输出:
app_session_index POST /app_session(.:format) app_session#create
app_session DELETE /app_session/:id(.:format) app_session#destroy
这里发生了什么?为什么要_index
添加到app_session
?肯定是这个问题...