aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/engine.rb')
-rw-r--r--railties/lib/rails/engine.rb29
1 files changed, 21 insertions, 8 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index e9ce9610b8..25ca8c4758 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -189,17 +189,14 @@ module Rails
# served by default. You should choose one of the two following strategies:
#
# * enable serving static files by setting config.serve_static_assets to true
- # * symlink engines' public directories in application's public directory by running
- # `rake ENGINE_NAME:install:assets`, where ENGINE_NAME is usually my_engine for the
- # examples above
+ # * copy engine's public files to application's public folder with rake ENGINE_NAME:install:assets, for example
+ # rake my_engine:install:assets
#
# == Engine name
#
- # There are some places where engine's name is used.
- #
+ # There are some places where engine's name is used:
# * routes: when you mount engine with mount(MyEngine::Engine => '/my_engine'), it's used as default :as option
- #
- # * rake tasks: engines have a few rake tasks. They are usually under my_engine namespace.
+ # * some of the rake tasks are based on engine name, e.g. my_engine:install:migrations, my_engine:install:assets
#
# Engine name is set by default based on class name. For MyEngine::Engine it will be my_engine_engine.
# You can change it manually it manually using engine_name method:
@@ -317,6 +314,10 @@ module Rails
#
# rake ENGINE_NAME:install:migrations
#
+ # Note that some of the migrations may be skipped if migration with the same name already exists
+ # in application. In such situation you must decide whether to leave that migration or rename the
+ # migration in application and rerun copying migrations.
+ #
# If your engine has migrations, you may also want to prepare data for the database in
# seeds.rb file. You can load that data using load_seed method, e.g.
#
@@ -509,7 +510,7 @@ module Rails
end
initializer :append_asset_paths do
- config.asset_path ||= "/#{engine_name}%s"
+ config.asset_path ||= "/#{railtie_name}%s"
public_path = paths["public"].first
if config.compiled_asset_path && File.exist?(public_path)
@@ -538,6 +539,12 @@ module Rails
next if self.is_a?(Rails::Application)
namespace railtie_name do
+ desc "Shortcut for running both rake #{railtie_name}:install:migrations and #{railtie_name}:install:assets"
+ task :install do
+ Rake::Task["#{railtie_name}:install:migrations"].invoke
+ Rake::Task["#{railtie_name}:install:assets"].invoke
+ end
+
namespace :install do
# TODO Add assets copying to this list
# TODO Skip this if there is no paths["db/migrate"] for the engine
@@ -546,6 +553,12 @@ module Rails
ENV["FROM"] = railtie_name
Rake::Task["railties:install:migrations"].invoke
end
+
+ desc "Copy assets from #{railtie_name} to application"
+ task :assets do
+ ENV["FROM"] = railtie_name
+ Rake::Task["railties:install:assets"].invoke
+ end
end
end
end