0
我有這個在我的.html.erb代碼:路由錯誤在Ruby on Rails的
$.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.');
}
});
這在我datasets_controller.rb
def timeMachineEdit
@dataset = current_user.dataset
@dataset.machine_time = params[:editTimeMachine]
end
而且在我的routes.rb:
match "/timeMachineEdit", to: "datasets#timeMachineEdit"
但是當submited顯示:
POST http://localhost:3000/timeMachineEdit 500 (Internal Server Error)
問題在哪裏? 是在ajax網址或其他東西的路線?
您有一個錯字:'match'/ tiempoMaquinaEdit「,':tiempoMaquinaEdit應該是'match'/ timeMachineEdit」 – MrYoshiji