diff options
author | John Hawthorn <john@hawthorn.email> | 2019-06-03 17:20:20 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2019-06-03 20:06:57 -0700 |
commit | 4ab00cfac0c5bda7b66c5f80c63a8e858d4eac02 (patch) | |
tree | 61eadc5fbf0f946a29422e92e63edc7c30fc0684 /actionpack | |
parent | 17424a7de15694432405f56f97424d50b2e908b5 (diff) | |
download | rails-4ab00cfac0c5bda7b66c5f80c63a8e858d4eac02.tar.gz rails-4ab00cfac0c5bda7b66c5f80c63a8e858d4eac02.tar.bz2 rails-4ab00cfac0c5bda7b66c5f80c63a8e858d4eac02.zip |
Use file/line from call to helper_module
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/abstract_controller/helpers.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 8ff214f220..abb09456e0 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -61,12 +61,17 @@ module AbstractController meths.flatten! self._helper_methods += meths + location = caller_locations(1, 1).first + file, line = location.path, location.lineno + meths.each do |meth| - _helpers.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1 - def #{meth}(*args, &blk) # def current_user(*args, &blk) - controller.send(%(#{meth}), *args, &blk) # controller.send(:current_user, *args, &blk) - end # end - ruby_eval + method_def = [ + "def #{meth}(*args, &blk)", + " controller.send(%(#{meth}), *args, &blk)", + "end" + ].join(";") + + _helpers.class_eval method_def, file, line end end |