Reputation: 5953
I have a Rails app with jquery-ui sortable lists. When the user drags from one list to another the wostatus_id field gets updated. So, it's failing on a jquery Ajax update.
This works fine in localhost and on Heroku. But, I'm moving the app to a Bitnami Virtual Server + Rails implementation. I don't know if it's related, but I'm using node.js on the new server.
On this new server, I'm getting this error on the browser console:
PUT http://ndeavor.ameipro.com/workorders/2 501 (Not Implemented)
This is the coffee script:
$("#sort1, #sort2, #sort3, #sort4, #sort5, #sort6, #sort7").sortable
connectWith: ".connectedSortable"
cursor: "move"
update: ->
$.post($(this).data('update-url'), $(this).sortable('serialize'))
receive: (event, ui) ->
str_id = $(ui.item).attr('id')
woid = str_id.split('_')[1]
$.update "/workorders/" + woid,
workorder:
wostatus_id: $(this).data('wostatus-id')
Thanks for the help!
UPDATE1
I'm getting the same error when I drag an event from one day to another using the fullcalendar-rails month view.
UDPATE2
I found this "Fixing 501 error code The client should specify a valid request type. Even after that if the Web server is responding incorrectly, then the web server simply needs to be upgraded to fix the issue."
I'm sure the request is OK - the same code has been running on localhost and Heroku for months. So, it has to be something to do with the new virtual server I'm using.
The new server is Bitnami Rails stack. It has node.js installed. I'm running Apache, Passenger and PG.
How would I upgrade the server to fix the problem???
UPDATE3
This coffeescript gets the same response:
updateEvent = (the_event) ->
$.update "/events/" + the_event.id,
event:
title: the_event.title,
starts_at: "" + the_event.start,
ends_at: "" + the_event.end,
description: the_event.description
UPDATE4
Could Apache be stopping the use of PUT? Maybe some setting in https.conf?
UPDATE5
The same app runs fine using Thin !!!! So, I'm going to try and use Nginx and Thin.
UPDATE6
I can't get it to work. So, I'm going to try Nginx and 5 Thin app servers.
UPDATE7
I now have the Rails app running on Nginx and 5 Thin servers. I still get the 501 PUT - jquery error !!!!
If I run Thin in stand-alone on port 3000, it works fine.
If I run Thin stand-alone on port 80, I get the same JQUERY PUT 501 error.
So, something is wrong with our servers using port 80.
Upvotes: 10
Views: 1292
Reputation: 1
Had the same issue, looking at the POUND reverse proxy server configuration as someone else suggested and changing the xHTTP to the value of 1 fixed it for me.
http://manpages.ubuntu.com/manpages/xenial/man8/pound.8.htmlSee ubuntu POUND config details
Upvotes: 0
Reputation: 5953
I spent almost 2 weeks working on this. I have tried Apache+Passenger and Nginx+Thin.
It ends up that none of those were the cause. It had nothing to do with the Rails app setup.
It was a Pound networking server that was stopping PUT.
Upvotes: 4
Reputation: 3195
well if your server apache is well configured with Virtualhost. using gem install passenger and passenger-install-apache2-module into your rails app. So he tells you what you need to add into your file httpd.conf. Usually you got something close to this.
Listen *:80
NameVirtualHosts *:80
LoadModule passenger_module /somewhere/passenger-x.x.x/ext/apache2/mod_passenger.so
PassengerRuby /usr/bin/ruby
PassengerRoot /somewhere/passenger/x.x.x
PassengerMaxPoolSize 10
<VirtualHost *:80>
ServerName www.foo.com
DocumentRoot /webapps/foo/public
RailsBaseURI /rails
</VirtualHost>
but i advice you to use Nginx with Passenger.
I also look at this : 501 Method Not Found error on a javascript file - change name and it then works - why?
Here you can find a tutorial to deploy Rails app with Apache : Rails 3.1 application deployment tutorial
Upvotes: 1
Reputation: 506
Have you tried synthesizing a request without the sortable? I have this sneaking suspicion that JUI is adding crazy temp elements that's formatting your request insanely.
Alternatively, whenever something works locally but not on the server, I figure that something isn't asynchronous that should be.
Instead of making a request on sort, log out the request's parameters. Do they make sense?
Upvotes: 1
Reputation: 30496
Check for the Limit keyword on your apache configuration.
chances are that by default you have something like that somewhere:
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
This prevent the web server from accepting any PUT or DELETE request, thus the 501 (Not Implemented).
UPDATE:
So the thing you have found are:
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
This means only GET
, POST
and OPTIONS
queries are accepted (allow from all
) and anything not in this list (LimitExcept
) is denied (Deny From All
).
If you need the PUT keyword then add it in theses two settings (Limit
and LimitExcept
).
Note that theses limits are only applied for /home/*/public_html
directories.
Upvotes: 2