Routing error in ajax on ruby on rails

I have this in my .html.erb code:

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]

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

rake routes will show you the routes that are valid. If you try that
I expect you will see that timeMachineEdit is only routed for GET.
You need to specify specifically if you want it to be valid for POST.
See the Rails Guide on Routing for more information.