aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view
diff options
context:
space:
mode:
authorAndrew White <andrew.white@unboxed.co>2017-01-15 13:41:39 +0000
committerAndrew White <andrew.white@unboxed.co>2017-01-15 13:41:39 +0000
commitb5edc55d9fc3f6fc87ab06b5897917e051a82aef (patch)
treedb6b8adacb9552cf7b67467d4a266af5f4562d23 /actionview/lib/action_view
parenteec4c2e978be15b85ba8f3efa054cb43acf1bdda (diff)
downloadrails-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/action_view')
-rw-r--r--actionview/lib/action_view/template.rb2
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}];" }