diff options
author | Joshua Peek <josh@joshpeek.com> | 2011-03-28 11:04:31 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2011-03-28 11:04:31 -0500 |
commit | 170680ae9179ea6ce35e1a2ca50ea474bf2126ab (patch) | |
tree | ea61eda72335790271dba84fd291064b430de694 | |
parent | ce52c6f4a74f7cb9d9e321203bb47f0f3364bfb2 (diff) | |
download | rails-170680ae9179ea6ce35e1a2ca50ea474bf2126ab.tar.gz rails-170680ae9179ea6ce35e1a2ca50ea474bf2126ab.tar.bz2 rails-170680ae9179ea6ce35e1a2ca50ea474bf2126ab.zip |
Add route for assets
-rw-r--r-- | railties/lib/rails/application.rb | 34 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 35 |
2 files changed, 35 insertions, 34 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 57672a1324..94819820bc 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -137,40 +137,6 @@ module Rails @config ||= Application::Configuration.new(find_root_with_flag("config.ru", Dir.pwd)) end - def self.default_sprockets_paths - [ - "app/assets", - "app/assets/javascripts", - "app/assets/stylesheets", - "vendor/plugins/*/app/assets", - "vendor/plugins/*/app/assets/javascripts", - "vendor/plugins/*/app/assets/stylesheets", - "vendor/plugins/*/assets", - "vendor/plugins/*/assets/javascripts", - "vendor/plugins/*/assets/stylesheets" - ] - end - - def assets - @assets ||= build_asset_environment - end - - def build_asset_environment - require 'sprockets' - - env = Sprockets::Environment.new(root.to_s) - env.logger = Rails.logger - env.static_root = Rails.root.join("public") - - self.class.default_sprockets_paths.each do |pattern| - Dir[root.join(pattern)].each do |dir| - env.paths << dir - end - end - - env - end - protected def default_asset_path diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 4fc23fe277..d0b245c595 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -434,10 +434,45 @@ module Rails def routes @routes ||= ActionDispatch::Routing::RouteSet.new + @routes.add_route(assets, {}, {}, {}, nil, false) @routes.append(&Proc.new) if block_given? @routes end + def self.default_sprockets_paths + [ + "app/assets", + "app/assets/javascripts", + "app/assets/stylesheets", + "vendor/plugins/*/app/assets", + "vendor/plugins/*/app/assets/javascripts", + "vendor/plugins/*/app/assets/stylesheets", + "vendor/plugins/*/assets", + "vendor/plugins/*/assets/javascripts", + "vendor/plugins/*/assets/stylesheets" + ] + end + + def assets + @assets ||= build_asset_environment + end + + def build_asset_environment + require 'sprockets' + + env = Sprockets::Environment.new(root.to_s) + env.logger = Rails.logger + env.static_root = root.join("public") + + self.class.default_sprockets_paths.each do |pattern| + Dir[root.join(pattern)].each do |dir| + env.paths << dir + end + end + + env + end + def initializers initializers = [] railties.all { |r| initializers += r.initializers } |