mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use file/line from call to helper_module
This commit is contained in:
parent
17424a7de1
commit
4ab00cfac0
1 changed files with 10 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue