We got an ActionView::MissingTemplate exception from a remote site using our embed code.
The exception was:
ActionView::MissingTemplate: Missing template /embed, application/embed with {:handlers=>[:erb, :builder, :haml], :formats=>["*/*;q=0.01"], :locale=>[:en, :en]}.
with these http headers:
HTTP_ACCEPT "*/*;q=0.01"
HTTP_ACCEPT_LANGUAGE "en"
HTTP_USER_AGENT "Mozilla/4.0 (PSP (PlayStation Portable); 2.00)"
The strange thing is that PSP is sending us this accept header:
HTTP_ACCEPT "*/*;q=0.01";
HTTP_ACCEPT is a http request header used by the client asking for the types of formats it can support. Typically, browsers send an list of acceptable formats. Google Chrome sends Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 which means that the server should try to send back an html or xml format with a preference value of q=0.9 and if not available, send anything else(*/*) with a preference value of q=0.8.
Unfortunately, since our Rails controller code explicitly only accepted html or json with a respond_to block, Rails didn’t interpret “*/*” as html.
respond_to :html, :json
render :layout => false
We can make the fix by explicitly render the default format as html:
render "embed.html", :layout => false