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 に答える