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
You have a route "assets", which is a reserved route in Rails and it is reserved for Rails Asset Pipeline.
If you must use the "assets" route then you need to give Asset Pipeline another mount point by adding the following line in your development.rb or production.rb configuration block:
config.assets.prefix = '/assetz'
And restart your server.
By this all your assets will be mounted on "/assetz" and you will be able to use POST requests on "/assets".
Happy coding!
Reference:
1) StackOverflow
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.
Could you post your routes file and also the exact rails version of your dev-environment and the production servers?
I assume this could happen when you post to a route that is only registered as a get request (depending on your rails version) or maybe routes that are defined twice, e.g.:
resources :photos, :only => [:index]
get :photos