0

我在以下代码部分遇到了这个奇怪的问题

<% 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

1 回答 1

1

在第 4 行,看

'view' ,:id

(把你的逗号移过来)我也想你在第 2 行也需要一个 :url 哈希

于 2009-11-06T20:39:31.977 回答