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]