1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Piotr Sarnacki 2010-09-29 17:46:59 +02:00
parent f851352318
commit 6648babded

View file

@ -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}"