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