diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-07 03:08:08 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-07 03:08:08 +0000 |
commit | 907d6ce28587593ec2bc93b4aeb216ca9d583a95 (patch) | |
tree | da40a488e64ad154a393d115faae29508aba3cd8 /railties | |
parent | f29ae1253538b1182c2cabfcfbcc8f8b70bab575 (diff) | |
download | rails-907d6ce28587593ec2bc93b4aeb216ca9d583a95.tar.gz rails-907d6ce28587593ec2bc93b4aeb216ca9d583a95.tar.bz2 rails-907d6ce28587593ec2bc93b4aeb216ca9d583a95.zip |
Extend the console +helper+ method to allow you to include custom helpers. Closes #6781 [Chris Wanstrath]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7765 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 4 | ||||
-rw-r--r-- | railties/lib/console_with_helpers.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index d8218f3715..a9d90f9ff7 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,9 @@ *SVN* +* Extend the console +helper+ method to allow you to include custom helpers. e.g: + >> helper :posts + >> helper.some_method_from_posts_helper(Post.find(1)) + * db:create works with remote databases whereas db:create:all only creates databases on localhost. #9753 [Trevor Wennblom] diff --git a/railties/lib/console_with_helpers.rb b/railties/lib/console_with_helpers.rb index 66a4248e0b..79018a9f76 100644 --- a/railties/lib/console_with_helpers.rb +++ b/railties/lib/console_with_helpers.rb @@ -10,8 +10,10 @@ class Module end end -def helper - @helper_proxy ||= Object.new +def helper(*helper_names) + returning @helper_proxy ||= Object.new do |helper| + helper_names.each { |h| helper.extend "#{h}_helper".classify.constantize } + end end require 'application' @@ -21,3 +23,4 @@ class << helper end @controller = ApplicationController.new +helper :application rescue nil |