Missing Partial (JSON Response) – Ruby on Rails

Hey everyone,

I’ve just added pagination (Kaminari) to make an infinite scroll list a little easier to use. Unfortunately, I ran into the following error – had me stumped for a while:

Missing partial /contents/content_list_item with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :coffee]}. Searched in:  * "/home/chris/funny/app/views"  * "/home/chris/.rvm/gems/ruby-1.9.3-p327/gems/kaminari-0.14.1/app/views"

The solution was fairly simple, but adding a few things at once had me looking at it the wrong way. Because I was using the same nested partials for an HTML response as my JSON one, the file extensions weren’t what rails was expecting. To get around this, all I needed to do was fully qualify the partial filenames. For instance:

#The original
<%= render :partial => '/contents/content_list_item', :locals => { :@content_item =>  content} %>
#Became this
<%= render :partial => '/contents/content_list_item.html.erb', :locals => { :@content_item => content} %>

Leave a Reply