Class: ActionView::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details

#i18n_auto_scoping_aliased_renderObject



4
# File 'lib/action_view_extension.rb', line 4

alias_method :i18n_auto_scoping_aliased_render, :render

#render(opts = {}, *args) ⇒ Object

To set a default scope for all render



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/action_view_extension.rb', line 7

def render(opts = {}, *args)
  old_auto_scope_in_render = Thread.current[:last_i18n_auto_scope_render_in_render]
  old_auto_scope = Thread.current[:last_i18n_auto_scope_render]
  Thread.current[:last_i18n_auto_scope_render_in_render] = true
  Thread.current[:last_i18n_auto_scope_render] = nil

  i18n_auto_scoping_aliased_render(opts, *args)
ensure
  Thread.current[:last_i18n_auto_scope_render] = old_auto_scope
  Thread.current[:last_i18n_auto_scope_render_in_render] = old_auto_scope_in_render
end