I'm diving into Ruby on Rails and building a web game where the user has to answer a question. I'm handling all the answer verification logic in Javascript in the browser so that my server doesn't have to. When my javascript code verifies that the answer is correct, my Javascript code will send a request to my Rails server to let it know that the user answered the question correctly using something like...
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
Since anyone can use a tool like curl to cheat and send a similar request, how can I ensure that the request is coming from the javascript in my Rails view?
Thanks so much in advance for your wisdom!