Permalink
Browse files

Add route for assets

  • Loading branch information...
1 parent ce52c6f commit 170680ae9179ea6ce35e1a2ca50ea474bf2126ab @josh josh committed Mar 28, 2011
Showing with 35 additions and 34 deletions.
  1. +0 −34 railties/lib/rails/application.rb
  2. +35 −0 railties/lib/rails/engine.rb
@@ -137,40 +137,6 @@ def config
@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
@@ -434,10 +434,45 @@ def env_config
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 }

0 comments on commit 170680a

Please sign in to comment.