In my Rails application, I am trying to use jQuery ajax to create a new element using the default create method in my controller.
My routes.rb as follows:
resources :items
Server-side code is still as it is created:
And my JavaScript:
$("#capture_input").focusout(function() { var description = $(this).val(); $.ajax({ type: "POST", url: '/items/create.json', data: { item: { description : description } }, dataType: 'json', success: function(msg) { alert( "Data Saved: " + msg ); } }); });
This seems very simple, but I get the following error:
ActionController::RoutingError (No route matches [POST] "/items/create.json"):
I could use the default update method in a similar situation without any problems. What is the problem?
EDIT: Fixed a typo in the route.rb file.
source share