1
在我的優惠券視圖中,我在helpers/coupons_helper.rb中調用了一個方法,該方法依次調用一個部分以返回它的輸出。但是我收到一個「Missing Template」錯誤。下面是相關代碼:Helper渲染會產生「Missing Template」錯誤
views/coupons/show.html.erb:
...
<%= form_for(@coupon) do |f| %>
<% new_include(f) %>
<% end %>
helpers/coupons_helper.rb:
def new_include(f)
new_object = Participation.new
fields = f.fields_for(:participation, new_object, :child_index => :new_include) do |builder|
render "_locations_include", :f => builder
end
end
views/coupons/_locations_include.html.erb:
Include: <%= f.select :participant_id, @groups %><br>
和錯誤消息是:
Missing partial coupons/_locations_include with {:handlers=>[:erb, :builder, :rjs, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in view paths "/Users/jackrg/Documents/YummiApps/yummi1/app/views"
原來,這個問題是導致「_」中的「渲染」,在「new_include」。問題解決了。
我會同意你的看法,但我有兩個偏見:一個叫locations_include,另一個叫locations_exclude。在發佈後大約15分鐘後(在發佈之前查看了一小時後),我發現我有一個無關的「_」,但我沒有足夠的狀態在我的問題發佈答案,直到8小時過去,所以我不得不接受我的同齡人對我的嘲笑;)無論如何,感謝您的觀察。 –