我现在正在尝试使用我的 javascript 在单击元素时使用此代码呈现新视图;
$(document).ready(function() {
$('.link-panel').click( function() {
window.location.replace('/quotes/'+gon.gon_quote_id);
});
});
我收到以下错误:
Couldn't find Quote with 'id'=undefined [WHERE "quotes"."user_id" = $1]
报价控制器.rb:
def show
@quote = current_user.quotes.find(params[:id])
gon.gon_quote_id = @quote.id
end
def index
@quotes = current_user.quotes.all
# how to pass the individual quote object's id to gon here
结尾
我认为这一定是我将 url 参数赋予replace
方法的方式,你能帮我解决我做错了什么吗?
(gon
如警报测试所示,设置工作正常。)
谢谢