Reputation: 353
I have the following problem. A web service is sending a JSON POST request 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?
Upvotes: 3
Views: 1267
Reputation: 65455
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
Upvotes: 3