Explicit formats in FileSystemResolver


I have a small research and wanna know what Rails-core team thinking about this problem (if it is problem).

By some reason Rails allow us use view template or layout without explicit extension.

For example we can use app/views/layouts/application.erb instead app/views/layouts/application.html.erb or any other a popular template system like haml or slim without throw any errors. All works as expected but when we try render XHR request, ActionView::Resolver::PathResolver missing format when try extract_handler_and_format_and_variant from path.


def extract_handler_and_format_and_variant(path, default_formats)
pieces = File.basename(path).split(".")

  extension = pieces.pop
  unless extension
      The file #{path} did not specify a template handler. The default is
      currently ERB, but will change to RAW in the future.

  handler = Template.handler_for_extension(extension)
  format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last
  format  &&= Template::Types[format]
  [handler, format, variant]



format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last this expression assign nil to format, so all other works with nil.

So where is a problem here?

If we have action that’s should remote render only async.js.erb template:

class HomeController < ApplicationController
def index

def async


This render home/async.js.erb within layouts/application. It is not expected behavior.

Why are my JS views rendering with my HTML layout wrapped around them?

js.erb file not being executed

and many other people with the same problem what i see on SO.

I stepped on a rake these too :slight_smile:

This is very hard to find problem

Only if add layout: false this working properly(or add html extension).

But i found this strange and not useful. I think this is Rails feature and should happen without explicit to declare.


def async
layout: false


Thanks for attention.

P.S. Sorry for my poor English.