Skip to content

Commit 5e3820b

Browse files
Hitabisctran
authored andcommitted
annotate --routes modifies only routes.rb (#485)
* annotate --routes modifies only routes.rb This change is a proposed solution to #357 and an alternative to the already proposed solution #361. In #361 it is needed to call `annotate --routes --ignore-models` to achieve the same as in this change with only `annotate --routes`. * Call eager_load only when models are included This to prevent activerecord model errors when using mongoid for example and calling `annotate --routes`
1 parent 330f8bd commit 5e3820b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bin/annotate

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ end.parse!
202202
options = Annotate.setup_options(
203203
is_rake: ENV['is_rake'] && !ENV['is_rake'].empty?
204204
)
205-
Annotate.eager_load(options)
205+
Annotate.eager_load(options) if Annotate.include_models?
206206

207207
AnnotateModels.send(target_action, options) if Annotate.include_models?
208208
AnnotateRoutes.send(target_action, options) if Annotate.include_routes?

lib/annotate.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def self.include_routes?
114114
end
115115

116116
def self.include_models?
117-
true
117+
ENV['routes'] !~ TRUE_RE
118118
end
119119

120120
def self.loaded_tasks=(val)

0 commit comments

Comments
 (0)