I am having an issue with my Rails localhost Server, all Post calls started returning 405 method not allowed. However there are no problems on our staging and production
In the ruotes.rb file, include your routes in a namespace, so it should look like this:
Rails.application.routes.draw do
namespace 'api' do
Your routes here
end
end
Then, add controllers corresponding to these routs in a folder with the same name of that namespace, so the app directory should look like this:
app
| controllers
| | api
| | | Your controller files here
Finally, the controllers should be inside a module with the same name of the namespace but with the first letter capital, so each controller should look like this:
module Api
Your controller code here
end
Note: You can give each related set of routes/controllers different namespaces/modules. Also, you can use nested namespaces/modules.