aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-09-29 17:46:59 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-30 09:47:06 +0200
commit6648babdedb8cb9494dec69d2f7efac3da1d239c (patch)
treeae512eec69c90a5c2642fc8f7103432e2c601640 /railties/lib/rails/commands.rb
parentf851352318c7468db310e5fbea0d86dc8b731c6d (diff)
downloadrails-6648babdedb8cb9494dec69d2f7efac3da1d239c.tar.gz
rails-6648babdedb8cb9494dec69d2f7efac3da1d239c.tar.bz2
rails-6648babdedb8cb9494dec69d2f7efac3da1d239c.zip
Allow running generators for Engine with usage of other application.
After that commit, developers can set ENGINE_PATH in ENGINE/scripts/rails file and load application's ./script/rails (most of the time it will be dummy application used for testing). When running ./script/rails g it will use application to boot up, but then it will use Engine's root and configuration for generators.
Diffstat (limited to 'railties/lib/rails/commands.rb')
-rw-r--r--railties/lib/rails/commands.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb
index 60a93c9848..acabdcac93 100644
--- a/railties/lib/rails/commands.rb
+++ b/railties/lib/rails/commands.rb
@@ -11,7 +11,17 @@ command = ARGV.shift
command = aliases[command] || command
case command
-when 'generate', 'destroy', 'plugin', 'benchmarker', 'profiler'
+when 'generate', 'destroy', 'plugin'
+ require APP_PATH
+ Rails.application.require_environment!
+
+ if defined?(ENGINE_PATH)
+ engine = Rails.application.railties.engines.find { |r| r.root.to_s == ENGINE_PATH }
+ Rails.application = engine
+ end
+ require "rails/commands/#{command}"
+
+when 'benchmarker', 'profiler'
require APP_PATH
Rails.application.require_environment!
require "rails/commands/#{command}"