0

I can't for the life of me get anywhere with this issue. I've searched everywhere with every keyword under the sun I can think of and I can't find a straightforward answer.

How do I enable HTTP PUT and DELETE for a Apache, Phusion Passenger, Rails 4 production server stack?

I'm incredibly confused why this is so difficult to get working. Peeps, what is the trick to enabling my AJAX PUT and DELETE requests to be accepted on the backend? This works when I just run Webrick for development on my local machine, but our production site doesn't appear to be accepting PUT and DELETE requests.

I can't even tell if this is an Apache issue, a Passenger issue, or what. Someone has to have done this setup with full REST capability. Or is this just not the technology for the job? (I'm not a server expert). In that case, what would you recommend?

Note: the rest of the application runs fine, it's only PUT/DELETE AJAX requests that are being aborted by the browser.

  • You can check whether it's Apache or not by using Passenger Standalone, which uses Nginx to serve its requests. Instead of running `rails server`, just run `passenger start`. Check whether that works. – Hongli Dec 19 '13 at 23:37
  • i use `sudo service apache2 start` to start my server which I assume calls `passenger start` at some point, but I don't know. – spiderdeveloper Dec 20 '13 at 00:06
  • It does not. `passenger start` starts Passenger Standalone, not Passenger for Apache. Passenger Standalone and Passenger for Apache are two completely different things. See http://www.modrails.com/documentation/Users%20guide.html – Hongli Dec 20 '13 at 09:07
  • I'm having the same problem. It works fine with `passenger start`. From information gathered elsewhere it seems Apache disallows PUT due to safety reasons. I think the reason only AJAX requests are affected is that Rails fakes normal PUT request by sending POST with an extra parameter. – Matijs van Zuijlen Jun 23 '15 at 12:11
  • D'oh! After fixing my code to use POST instead, it turned out the wrong URL was used, accessing a path outside of Rails. – Matijs van Zuijlen Jun 23 '15 at 12:56

1 Answers1

0

I had the same problem and it turned out to be a problem of our rails app.

The pointer was a line in my /var/log/apache2/error.log:

ActionController::RoutingError (No route matches [GET] "/javascripts/application.js")

The solution was to put

config.assets.compile = true

in config/environments/production.rb and precompiling the assets before the server is started

rake assets:precompile

I found this solution in this answer.

You probably also want to look at the blog post that he linked.

Community
  • 1
  • 1
fap
  • 663
  • 1
  • 5
  • 14