簡體   English   中英

Rails 2.1中link_to_remote的問題

[英]problem with link_to_remote in Rails 2.1

我在以下代碼段中遇到了這個奇怪的問題

<% if (@more == -1) %>
  <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%>
<% else %>
  <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => @more.to_i + 1} , :html => {:id => 'more-link'} %>
<% end %>

現在,當我使用此代碼時,出現以下錯誤

You have a nil object when you didn't expect it!You might have expected an instance of ActiveRecord::Base.The error occurred while evaluating nil.[]

錯誤似乎也在這一行。

  <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%>

因此,無法真正弄清楚為什么這行不通嗎?

在第4行,看看

'view' ,:id

(將逗號移開)我也在想,您也需要在第2行使用:url散列

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM