Skip to content
This repository
Browse code

Remove app/views from the load paths [#4226 state:resolved]

  • Loading branch information...
commit c140aca361506a3a759fbe03fad8adc748c807bb 1 parent 6690d66
José Valim authored April 05, 2010
2  railties/lib/rails/engine/configuration.rb
@@ -20,7 +20,7 @@ def paths
20 20
           paths.app.models          "app/models",          :eager_load => true
21 21
           paths.app.mailers         "app/mailers",         :eager_load => true
22 22
           paths.app.metals          "app/metal",           :eager_load => true
23  
-          paths.app.views           "app/views",           :eager_load => true
  23
+          paths.app.views           "app/views"
24 24
           paths.lib                 "lib",                 :load_path => true
25 25
           paths.lib.tasks           "lib/tasks",           :glob => "**/*.rake"
26 26
           paths.config              "config"
22  railties/lib/rails/paths.rb
@@ -3,6 +3,8 @@
3 3
 module Rails
4 4
   module Paths
5 5
     module PathParent
  6
+      attr_reader :children
  7
+
6 8
       def method_missing(id, *args)
7 9
         name = id.to_s
8 10
 
@@ -37,15 +39,15 @@ def all_paths
37 39
       end
38 40
 
39 41
       def load_once
40  
-        filter { |path| path.paths if path.load_once? }
  42
+        filter_by(:load_once?)
41 43
       end
42 44
 
43 45
       def eager_load
44  
-        filter { |path| path.paths if path.eager_load? }
  46
+        filter_by(:eager_load?)
45 47
       end
46 48
 
47 49
       def load_paths
48  
-        filter { |path| path.paths if path.load_path? }
  50
+        filter_by(:load_path?)
49 51
       end
50 52
 
51 53
       def push(*)
@@ -58,8 +60,16 @@ def push(*)
58 60
 
59 61
     protected
60 62
 
61  
-      def filter(&block)
62  
-        all_paths.map(&block).compact.flatten.uniq.select { |p| File.exists?(p) }
  63
+      def filter_by(constraint)
  64
+        all_paths.map do |path|
  65
+          if path.send(constraint)
  66
+            paths  = path.paths
  67
+            paths -= path.children.values.map { |p| p.send(constraint) ? [] : p.paths }.flatten
  68
+            paths
  69
+          else
  70
+            []
  71
+          end
  72
+        end.flatten.uniq.select { |p| File.exists?(p) }
63 73
       end
64 74
     end
65 75
 
@@ -129,10 +139,12 @@ def load_path?
129 139
 
130 140
       def paths
131 141
         raise "You need to set a path root" unless @root.path
  142
+
132 143
         result = @paths.map do |p|
133 144
           path = File.expand_path(p, @root.path)
134 145
           @glob ? Dir[File.join(path, @glob)] : path
135 146
         end
  147
+
136 148
         result.flatten!
137 149
         result.uniq!
138 150
         result
1  railties/test/application/paths_test.rb
@@ -71,6 +71,7 @@ def assert_not_in_load_path(*path)
71 71
       assert_in_load_path "lib"
72 72
       assert_in_load_path "vendor"
73 73
 
  74
+      assert_not_in_load_path "app", "views"
74 75
       assert_not_in_load_path "app", "metal"
75 76
       assert_not_in_load_path "config"
76 77
       assert_not_in_load_path "config", "locales"

0 notes on commit c140aca

Please sign in to comment.
Something went wrong with that request. Please try again.