When I try to hit this action via Javascript, I get a 406 Not Acceptable
error:
def show
@annotation = Annotation.find_by_id(params[:id])
For me it was a simple before_filter that was restricting a action that renders a js file, once I added the :except => [:action] to the before_filter block it was fine.
Another insidious "Gotcha" here is if you call your controller with a form_for that accidentally has an additional not-necessary parameter. The additional parameter can be interpreted by Rails as a format request, and you'll get the 406.
Example:
= form_for parking_permit, url: permit_group_parking_permits_path(@permit_group.id, useless_id), method: :get do |f|
...
In the example above, you RAKE ROUTES and determine that permit_group_parking_permits_path does NOT need anything but the permit_group id...
If you see your method being called such as /model/action.1?blahblahblah that ".1" is your tip-off.
This will return the 406. We won't talk about how much time I spent on this once.
Is this served through Apache? You may want to take a look at http://forums.alwayswebhosting.com/showthread.php?p=8381, which describes scenarios where security policy interferes with requests.
EDIT: The URL referenced above advocates turning off request-sniffing security policy across an entire site, which makes the site vulnerable. Setting the SecFilterEngine option to Off in the .htaccess, which is what is prescribed in the URL, should be done only to zero in on the source of the problem. It should not be considered a long term solution.
include "format.js" in your respond_to block
Check your application.js for require jquery_ujs
//= require jquery_ujs
Just use this code in controller action method format block:
format.js { render :nothing => true }