I have this in my .html.erb code:
$.ajax({ url: "/timeMachineEdit", data: {editTimeMachine: newArray}, type: 'POST', success: function (res) { if (res.result === 'ok') { alert('Data saved'); } else { alert('Save error'); } }, error: function () { alert('Save error.'); } });
This in my datasets_controller.rb
def timeMachineEdit @dataset = current_user.dataset @dataset.machine_time = params[:editTimeMachine] end
And in my routes.rb:
match "/timeMachineEdit", to: "datasets#timeMachineEdit"
But when is submited shows:
POST http://localhost:3000/timeMachineEdit 500 (Internal Server Error)
Where is the problem here? is the routes in the ajax url or something else?