Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/branches/2-1-caching/railties/lib/console_with_helpers.rb

Revision 7765, 0.6 kB (checked in by nzkoz, 1 year ago)

Extend the console +helper+ method to allow you to include custom helpers. Closes #6781 [Chris Wanstrath]

Line 
1 class Module
2   def include_all_modules_from(parent_module)
3     parent_module.constants.each do |const|
4       mod = parent_module.const_get(const)
5       if mod.class == Module
6         send(:include, mod)
7         include_all_modules_from(mod)
8       end
9     end
10   end
11 end
12
13 def helper(*helper_names)
14   returning @helper_proxy ||= Object.new do |helper|
15     helper_names.each { |h| helper.extend "#{h}_helper".classify.constantize }
16   end
17 end
18
19 require 'application'
20
21 class << helper
22   include_all_modules_from ActionView
23 end
24
25 @controller = ApplicationController.new
26 helper :application rescue nil
Note: See TracBrowser for help on using the browser.