mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't polute the top level namespace in the console with ActionView helpers. Make them available from a helper method.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4019 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
4a968d464b
commit
cb069ea7cc
2 changed files with 12 additions and 4 deletions
|
@ -1,10 +1,10 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
* Make all ActionView helpers available in the console for debugging purposes. n.b.: Only an 80% solution. Some stuff won't work, most will. [Marcel Molina Jr.]
|
* Make all ActionView helpers available in the console from the helper method for debugging purposes. n.b.: Only an 80% solution. Some stuff won't work, most will. [Marcel Molina Jr.]
|
||||||
|
|
||||||
ex.
|
ex.
|
||||||
|
|
||||||
>> puts options_for_select([%w(a 1), %w(b 2), %w(c 3)])
|
>> puts helper.options_for_select([%w(a 1), %w(b 2), %w(c 3)])
|
||||||
<option value="1">a</option>
|
<option value="1">a</option>
|
||||||
<option value="2">b</option>
|
<option value="2">b</option>
|
||||||
<option value="3">c</option>
|
<option value="3">c</option>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Kernel
|
class Module
|
||||||
def include_all_modules_from(parent_module)
|
def include_all_modules_from(parent_module)
|
||||||
parent_module.constants.each do |const|
|
parent_module.constants.each do |const|
|
||||||
mod = parent_module.const_get(const)
|
mod = parent_module.const_get(const)
|
||||||
|
@ -10,6 +10,14 @@ module Kernel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def helper
|
||||||
|
@helper_proxy ||= Object.new
|
||||||
|
end
|
||||||
|
|
||||||
require 'application'
|
require 'application'
|
||||||
|
|
||||||
|
class << helper
|
||||||
|
include_all_modules_from ActionView
|
||||||
|
end
|
||||||
|
|
||||||
@controller = ApplicationController.new
|
@controller = ApplicationController.new
|
||||||
include_all_modules_from ActionView
|
|
||||||
|
|
Loading…
Reference in a new issue