Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Ignore Rails models autoload #106

Closed
wants to merge 2 commits into from

9 participants

AlexanderPav... added some commits
@sars

+

@jerodsanto

+1 to this PR. I have a pretty vanilla app on Rails 3.2.11 and relying on Rails' model autoloading was making annotate miss all of my models.

Switching to @AlexanderPavlenko's fork with this commit in it fixes the problem.

@marcusmateus

+1 I too had a vanilla Rails 3.2.11 app that Rails' autoloading made miss many of my models. Just monkey patching the change in this commit for now.

@SamSaffron

also broken on discourse, had to fork and source my fork.

@turadg turadg commented on the diff
bin/annotate
@@ -119,7 +119,7 @@ OptionParser.new do |opts|
end
end
- opts.on('-e', '--exclude [tests,fixtures,factories]', ['tests','fixtures','factories'], "Do not annotate fixtures, test files, and/or factories") do |exclusions|
+ opts.on('-e', '--exclude [tests,fixtures,factories]', Array, "Do not annotate fixtures, test files, and/or factories") do |exclusions|
@turadg
turadg added a note

Why remove the list of options? The ones in the array literal are the only that have an effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ctran ctran closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. fix namespaced models problem

    AlexanderPavlenko authored
  2. fix OptionParser::InvalidArgument error

    AlexanderPavlenko authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 3 deletions.
  1. +1 −1  bin/annotate
  2. +1 −2  lib/annotate/annotate_models.rb
View
2  bin/annotate
@@ -119,7 +119,7 @@ OptionParser.new do |opts|
end
end
- opts.on('-e', '--exclude [tests,fixtures,factories]', ['tests','fixtures','factories'], "Do not annotate fixtures, test files, and/or factories") do |exclusions|
+ opts.on('-e', '--exclude [tests,fixtures,factories]', Array, "Do not annotate fixtures, test files, and/or factories") do |exclusions|
@turadg
turadg added a note

Why remove the list of options? The ones in the array literal are the only that have an effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
end
View
3  lib/annotate/annotate_models.rb
@@ -360,8 +360,7 @@ def get_model_files(options)
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
def get_model_class(file)
- # this is for non-rails projects, which don't get Rails auto-require magic
- require File.expand_path("#{model_dir}/#{file}") unless Module.const_defined?(:Rails)
+ require File.expand_path("#{model_dir}/#{file}")
model_path = file.gsub(/\.rb$/, '')
get_loaded_model(model_path) || get_loaded_model(model_path.split('/').last)
end
Something went wrong with that request. Please try again.