I have this in my rails route:
scope '/api' do
# ...
resources :callbacks, only: [:create]
end
It was working (returning a 500 error) but I fixed that and suddenly I get a 404 error when this is run this bit of coffeescript:
$('.add-callback button').on 'click', (e) ->
$form = $(@).parent()
$data =
notes: $form.find('[name="callback-notes"]').val()
date : $form.find('[name="callback-date"]').val()
time : $form.find('[name="callback-time"]').val()
$.ajax
type: "POST",
url: "/api/callbacks",
data: $data,
success: (data) ->
if data.success
$form.fadeOut ->
location.reload true
and it returns this:
POST http://localhost:3000/api/callbacks 404 (Not Found)
But POST /api/callbacks is found in the list of valid routes when you get a 404 anywhere else:
callbacks_path POST /api/callbacks(.:format) callbacks#create
Any ideas?
http://localhost:3000/api/callbacksinto your browser address bar? In theory, I'd expect you to get an error because of using GET rather than POST, but if you get a 404 that would suggest an avenue of investigation... Or usewgetorcurlor similar to actually do a POST to it. It's extremely unlikely that jQuery is the issue here.CuRLbut I getInvalid authenticity token