Browse files

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.
  • Loading branch information...
1 parent f851352 commit 6648babdedb8cb9494dec69d2f7efac3da1d239c @drogus drogus committed Sep 29, 2010
Showing with 11 additions and 1 deletion.
  1. +11 −1 railties/lib/rails/commands.rb
12 railties/lib/rails/commands.rb
@@ -11,7 +11,17 @@
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
require "rails/commands/#{command}"

0 comments on commit 6648bab

Please sign in to comment.