I'm trying to query our database on the .click function. I can alert(val) so that's working. But I'm trying to figure out how to go to the database and find out if a record in Discount table exists where Discount.amount == val
$(document).ready ->
$("button.discount").click ->
val = $('input.discount').val()
store = window.location.pathname.split('/')[1]
// Would like to do something like this, I'm guessing with ajax:
d = Discount.find_by_name(val)
if d
return d.amount
else
return "No discount exists"
end