Skip to content

Not finding model AB::Thing in ab/thing.rb #271

Closed
@anthonyjsmith

Description

@anthonyjsmith

I have an app with a model AB::Thing (rails 4.2.3):

rails new TestApp
cd TestApp/
rails g model AB::Thing
# First replace Ab with AB in app/models/ab.rb and app/models/thing.rb
rake db:migrate

Trying to annotate:

echo "gem 'annotate', github: 'ctran/annotate_models', branch: 'develop'" >> Gemfile
bundle
bundle exec annotate

Output:

Unable to annotate app/models/ab/thing.rb: cannot load a model from app/models/ab/thing.rb
Unable to annotate app/models/ab.rb: Unable to autoload constant Ab, expected /Users/anthonys/TestApp/app/models/ab.rb to define it
Nothing to annotate.

Hacking the source code and changing rescue to rescue LoadError in get_loaded_model seems to fix it (not sure if it will break anything else though):

Unable to annotate app/models/ab.rb: cannot load a model from app/models/ab.rb
Annotated (1): AB::Thing

(It's basically caused by the ambiguity between camelize and underscore with multiple uppercase letters.)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions