我正在通過ajax我的應用程序加載的一部分,我將它設置了所有,我clikc已設置remote: true
鏈接,請求正確的URL,但在控制檯中我得到一個500錯誤和以下:Rails的Ajax內部服務器錯誤
發起者在2014年1月8日18時46分08秒 0000處理由CoastersController#索引作爲參數JS GET 「/杯墊頁= 18?」 爲127.0.0.1:{ 「網頁」=> 「18」}呈現的共享/ _fact-bar.html.erb(0.9ms)渲染 杯墊/ index.html.erb(1.5毫秒)已完成500內部服務器錯誤在 3ms的
NoMethodError - 未定義的方法
each_with_index' for nil:NilClass:
_app_views_shared__fact_bar_html_erb__2012545158101504906_70360428754860' ActionPack的(3.2.12)LIB/ACTION_VIEW/template.rb:145:在
app/views/shared/_fact-bar.html.erb:6:inblock in render' activesupport (3.2.12) lib/active_support/notifications.rb:125:in
儀器 'ActionPack的 (3.2.12)LIB/ACTION_VIEW/template.rb:143:在`渲染'
我不太確定哪部分導致錯誤。任何幫助追蹤它?
事實巴分:
<div class="facts bar bar--white-wave">
<div class="container--padded">
<h1>Facts & Statistics</h1>
<ul class="fact-circle-container">
<% circleCount = 1 %>
<% @stats.each_with_index do |stat, i| %>
<% if stat[:active] == 1 then %>
<li>
<% if stat[:link] then %>
<a href="<%= stat[:link] %>">
<% end %>
<div class="fact-circle fact-circle--<%= circleCount %>" data-number="20">
<div class="inner">
<span><%= stat[:value] %></span>
</div>
</div>
<% if stat[:link] then %>
</a>
<% end %>
<h3 class="fact-circle__title"><%= stat[:name] %></h3>
</li>
<% circleCount = circleCount + 1 %>
<% end %>
<% end %>
</ul>
</div>
</div>
你能向我們展示fact-bar.html.erb部分嗎? 看起來你可能會調用each_with_index的東西不是Enumerable類型。 – toolz
你在'_fact-bar'部分調用'each_with_index'來指定'nil'。 – kddeisz
你有寫在那裏的一切:文件應用程序/視圖/共享/ _fact-bar.html.erb,第6行。你試圖調用each_with_index變量返回nil。 – BroiSatse