diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-01-15 13:41:39 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-01-15 13:41:39 +0000 |
commit | b5edc55d9fc3f6fc87ab06b5897917e051a82aef (patch) | |
tree | db6b8adacb9552cf7b67467d4a266af5f4562d23 /actionview/lib | |
parent | eec4c2e978be15b85ba8f3efa054cb43acf1bdda (diff) | |
download | rails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.tar.gz rails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.tar.bz2 rails-b5edc55d9fc3f6fc87ab06b5897917e051a82aef.zip |
Allow render locals to be assigned to instance variables
In #26672 we blocked use of Ruby keywords as identifiers for view
locals but inadvertently broke the use of instance variable names
as identifiers. Whilst not explicitly documented this behavior has
been around for a long time and there's no need to break it now.
Fixes #27480.
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/template.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 4b793c3b16..c067031d2d 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -326,7 +326,7 @@ module ActionView # Only locals with valid variable names get set directly. Others will # still be available in local_assigns. locals = @locals - Module::RUBY_RESERVED_KEYWORDS - locals = locals.grep(/\A(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/) + locals = locals.grep(/\A@?(?![A-Z0-9])(?:[[:alnum:]_]|[^\0-\177])+\z/) # Double assign to suppress the dreaded 'assigned but unused variable' warning locals.each_with_object("") { |key, code| code << "#{key} = #{key} = local_assigns[:#{key}];" } |