2009-11-06 31 views
0

我面臨着下面的代碼段這個奇怪的問題,現在問題與Rails的link_to_remote 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;'}%> 

所以不能真正搞清楚爲什麼這不起作用?

回答

1

第4行,看

'view' ,:id 

(移動您的逗號以上) 也是我想你需要一個:第2行以及

+0

URL哈希是啊,這工作我添加了一個:第2行的網址哈希,令人驚訝的是它在軌道2.3.4中運行良好。謝謝!!! – Shiv 2009-11-06 21:27:40

+0

是的,我沒有看到文檔,但我想它需要一個URL,因爲它畢竟是一個鏈接 – tybro0103 2009-11-08 20:37:02