Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Layout lookup fails when a template has locale in its filename

#3776

In Rails3 I get an error when trying to render a template with locale in its filename.

The repro code is (copied from the attached test):

class WithLocaleInTemplate < Base
  layout "hello"

  def index
    render 'hello_world'
  end
end

hello_world, for example, is hello_world.en.html.erb

Exception I get:

  NoMethodError: You specified nil as the layout, but no such method was found
      rails/actionpack/lib/abstract_controller/layouts.rb:397:in `_default_layout'

Actual exception is

 undefined method `|' for :en:Symbol
 rails/actionpack/lib/action_view/template/resolver.rb:15:in `register_detail'
 rails/actionpack/lib/action_view/template/resolver.rb:59:in `call'
 rails/actionpack/lib/action_view/template/resolver.rb:59:in `normalize_detail'

but it's hidden behind rescue NoMethodError in _default_layout.

The fix is one-liner:

  -        locale  = details.last && details.pop.to_sym
  +        locale  = details.last && [details.pop.to_sym]

Reported by Eugene Pimenov · January 24th, 2010 @ 02:09 AM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Eugene Pimenov
    Eugene Pimenov

    DeOMGfying has introduced conflicts to the patch. Nothing else has changed in patch.

    February 4th, 2010 @ 02:53 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to resolved
    • Importance changed from to Low

    I manually applied the test and it passed. This must have been fixed along the way.

    October 7th, 2010 @ 11:25 AM