开发者

POST request on Heroku doesn't work

I have the following problem. A web service is sending a JSON POST request开发者_如何学Python to my app on Heroku and I want to parse it.

If I look into my Heroku logs, I see that there was a POST request but it got an error

ActionController::RoutingError (No route matches....)

But a GET request works fine, no error.

I'm pretty new to Rails so I don't know what's wrong. Any ideas?


All paths (URLs), with their associated HTTP verbs and with other associated constraints, must be declared in config/routes.rb.

# config/routes.rb (Rails 3)
MyApp::Application.routes.draw do

  get 'my-service' => 'service#index' # ServiceController#index
  post 'my-service' => 'service#update' # ServiceController#update

end

Once routes are defined, Rails will respond to the corresonding verb/path the way you specify - usually, loading the controller and running the action you specify.

# app/service_controller.rb
class ServiceController < ApplicationController

  def index
    # do reading/displaying stuff here
  end

  def update
    # do updating stuff here
  end

end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜