0
我想查詢我們的數據庫.click函數。我可以提醒(val)以便工作。但我想弄清楚如何去到數據庫中,並找出如果折扣表中的記錄存在,其中Discount.amount == VAL使用ajax查詢數據庫是否存在項目。 Rails 3
$(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