2013-11-24 19 views
0

我有麻煩了。我不知道如何解決下面的問題。你能給我一些建議嗎?被調用的ID爲零,這將錯誤地爲4

現在我有一條錯誤消息。在/ 名爲id爲無, RuntimeError這將誤爲4 - 如果你真的想零的ID,請使用OBJECT_ID

塊 _app_views_members_show_html_erb__17546xx63197x72440_70098x3x384700app /視圖中的錯誤消息中提到的代碼/members/show.html.erb

當我在下面的代碼的「限制」後面加上「15」,我有錯誤,但是當我把「10」,我沒有錯誤信息......它只發生當我嘗試顯示本地主機:3000 /會員/ 1。

☆members_show(圖)

 <div class="message_area"> 
      <% posts_in_groups = GroupMessage.where(:member_id => params[:id]).order("created_at desc").limit(15) %> 
      <%# posts_in_groups.each{|post_in_group| post_in_group }%> 
      <div class="each_message"> 
      <% posts_in_groups.each do |post_in_group|%> 
       <a href="/groups/<%= post_in_group.group.id %>" ><%= image_tag post_in_group.group.imageurl, :width => '20', :height => '25' %><%= "(" + post_in_group.group.name + ")" %></a> 
       <%= 'Page:' + post_in_group.page.to_s + '&' %><%= 'Line:' + post_in_group.line.to_s %> 
       (<%= post_in_group.created_at.strftime'%Y-%m-%d %H:%M' %>) 
       <div class="group_message"> 
       <p class="message_content"><a href="/group_messages/<%= post_in_group.id%>" ><%= post_in_group.content %></a></p> 
       </div> 
      <br> 
      <% end %> 
      </div><!--each message-- > 
     </div><!--message area--> 
+1

不知道你是否已經這麼做了,但是你有沒有考慮過使用[Facebook-Omniauth](https://github.com/mkdynamic/omniauth-facebook)gem?您也可以觀看[this railscast](http://railscasts.com/episodes/360-facebook-authentication),其中討論了您正在嘗試做的具體事情。 –

+0

非常感謝Tamer先生。我已經使用過它。準確地說,我做了正式的登錄系統,之後,我建立了Facebook登錄系統。特別是在[:login]和[:user_id]中有一種衝突。 –

+0

複製並粘貼實際錯誤以及錯誤中提到的任何代碼行。 – tyler

回答

1

鍵入Rail.logger線的循環開始之後。

<% posts_in_groups.each do |post_in_group|%> 
<% Rails.logger.info "-----------------------#{post_in_group.group.id}" %>` 

然後看看控制檯,它應該顯示出它在出錯之前得到的記錄。

+0

非常感謝,fatfrog先生。我不知道在放入「Rails.logger.info」後應該做什麼,但是我確認了「post_in_group」的內容,然後顯示了第51組消息。所以我刪除它並解決了問題。 –

+0

這很好,你明白了。關於Rails.logger信息 - 你在開發時使用控制檯嗎? – fatfrog

+0

謝謝fatfrog先生。我總是使用rails控制檯,但我不確定在這種情況下如何使用它。 –

相關問題