Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle exec annotate doesn't run on models, just routes #563

Closed
jywei opened this issue Jun 5, 2018 · 19 comments · Fixed by #647
Closed

bundle exec annotate doesn't run on models, just routes #563

jywei opened this issue Jun 5, 2018 · 19 comments · Fixed by #647
Assignees
Milestone

Comments

@jywei
Copy link

jywei commented Jun 5, 2018

When I run bundle exec annotate --exclude tests,fixtures,factories,serializers, I will only get
config/routes.rb unchanged. (expectation: Model files unchanged. and config/routes.rb unchanged.
However, I need to run it with rake, with bundle exec rake annotate_models, annotate will finally run with my models.
It means my after migration auto-hook also doesn't work on models (also only routes)

annotate v2.7.4
Rails 5.1.4
ruby 2.5.1p57

if Rails.env.development?
  require 'annotate'
  task :set_annotation_options do
    # You can override any of these by setting an environment variable of the
    # same name.
    Annotate.set_defaults(
      'routes'                     => 'true',
      'position_in_routes'         => 'before',
      'position_in_class'          => 'before',
      'position_in_test'           => 'before',
      'position_in_fixture'        => 'before',
      'position_in_factory'        => 'before',
      'position_in_serializer'     => 'before',
      'show_foreign_keys'          => 'true',
      'show_complete_foreign_keys' => 'false',
      'show_indexes'               => 'false',
      'simple_indexes'             => 'false',
      'model_dir'                  => 'app/models',
      'root_dir'                   => '',
      'include_version'            => 'false',
      'require'                    => '',
      'exclude_tests'              => 'true',
      'exclude_fixtures'           => 'true',
      'exclude_factories'          => 'true',
      'exclude_serializers'        => 'true',
      'exclude_scaffolds'          => 'true',
      'exclude_controllers'        => 'true',
      'exclude_helpers'            => 'true',
      'exclude_sti_subclasses'     => 'false',
      'ignore_model_sub_dir'       => 'false',
      'ignore_columns'             => nil,
      'ignore_routes'              => nil,
      'ignore_unknown_models'      => 'false',
      'hide_limit_column_types'    => 'integer,boolean',
      'hide_default_column_types'  => 'json,jsonb,hstore',
      'skip_on_db_migrate'         => 'false',
      'format_bare'                => 'true',
      'format_rdoc'                => 'false',
      'format_markdown'            => 'false',
      'sort'                       => 'false',
      'force'                      => 'false',
      'classified_sort'            => 'true',
      'trace'                      => 'false',
      'wrapper_open'               => nil,
      'wrapper_close'              => nil,
      'with_comment'               => 'true'
    )
  end

  Annotate.load_tasks
end

TL;DR
Model annotation doesn't run on command line, only on rake version, HELP :(

@ctran
Copy link
Owner

ctran commented Jun 13, 2018

@jywei Sorry, I don't quite understand what the problem is with your description.

Did this work on some version and stop working with certain version?

@ctran ctran added the reviewed label Jun 13, 2018
@jywei
Copy link
Author

jywei commented Jun 13, 2018

Model annotation only works when I run bundle exec rake annotate_models
It doesn't when I run bundle exec annotate --exclude tests,fixtures,factories,serializers or the callback after migration

@ZeroInputCtrl
Copy link

ZeroInputCtrl commented Jun 19, 2018

yea, my annotate stopped working once i upgraded to 2.7.4 when it goes to annotate migration and rollbacks. Only tries to annotate routes now. Was working on 2.7.2 except for the issues in #538
Using rails 5.0.6

@blimey85
Copy link

I'm having the same problem. bundle exec rake annotate_models works fine but just running annotate which is how I've called it previously, only updates my routes file.

@hallmatt
Copy link

I'm having the same problem with version 2.7.4. Rails 5.2.1

@tcox5698
Copy link

Hi! I'm having the same problem.
annotate (2.7.4)
rails (5.2.1)

I am able to work around it with: bundle exec rake annotate_models

@vladvinnikov
Copy link

vladvinnikov commented Nov 5, 2018

I have same issue. It's added in #485.

Main reason - if you have routes = true in Annotate.set_defaults, then annotate_models doesn't called.
(Annotate.include_models? == false)

@jjercx
Copy link

jjercx commented Nov 30, 2018

I have same problem. annotate or bundle exec annotate does not annotate models. Only routes. And I have only changed auto_annotate_modes.rake in 'routes' => 'true'

# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
  require 'annotate'
  task :set_annotation_options do
    # You can override any of these by setting an environment variable of the
    # same name.
    Annotate.set_defaults(
      'routes'                    => 'true',
      'position_in_routes'        => 'after',
      'position_in_class'         => 'before',
      'position_in_test'          => 'before',
      'position_in_fixture'       => 'before',
      'position_in_factory'       => 'before',
      'position_in_serializer'    => 'before',
      'show_foreign_keys'         => 'true',
      'show_complete_foreign_keys' => 'false',
      'show_indexes'              => 'true',
      'simple_indexes'            => 'false',
      'model_dir'                 => 'app/models',
      'root_dir'                  => '',
      'include_version'           => 'false',
      'require'                   => '',
      'exclude_tests'             => 'false',
      'exclude_fixtures'          => 'false',
      'exclude_factories'         => 'false',
      'exclude_serializers'       => 'false',
      'exclude_scaffolds'         => 'true',
      'exclude_controllers'       => 'true',
      'exclude_helpers'           => 'true',
      'exclude_sti_subclasses'    => 'false',
      'ignore_model_sub_dir'      => 'false',
      'ignore_columns'            => nil,
      'ignore_routes'             => nil,
      'ignore_unknown_models'     => 'false',
      'hide_limit_column_types'   => 'integer,boolean',
      'hide_default_column_types' => 'json,jsonb,hstore',
      'skip_on_db_migrate'        => 'false',
      'format_bare'               => 'true',
      'format_rdoc'               => 'false',
      'format_markdown'           => 'false',
      'sort'                      => 'false',
      'force'                     => 'false',
      'classified_sort'           => 'true',
      'trace'                     => 'false',
      'wrapper_open'              => nil,
      'wrapper_close'             => nil,
      'with_comment'              => true
    )
  end

  Annotate.load_tasks
end

It does not work after migrate either.

Ruby 2.5.3
Rails 5.2.1
annotate 2.7.4

@ctran ctran added the bug label Feb 14, 2019
@ctran ctran self-assigned this Feb 14, 2019
@ctran ctran added this to the v.2.7.5 milestone Feb 14, 2019
@dinjas
Copy link

dinjas commented Feb 15, 2019

FWIW, I have noticed that any time I use the -r flag annotate will only update annotations in the routes file.

@ksouthworth
Copy link

I'm also experiencing this, any idea when v2.7.5 release is coming with the fix? Thanks!

@jmschneider
Copy link

I'm also experiencing this. Does this relate to the changes from issue #485?

@alexventuraio
Copy link

alexventuraio commented Apr 13, 2019

I have the same problem, after modifying the options 'routes' => 'true', when running rake db:migrate it just don't work anymore until manually run be rake annotate_models.

Ruby: 2.5.3
Rails: 5.2.0
Annotate: 2.7.4

@ctran
Copy link
Owner

ctran commented May 8, 2019

2.7.5 was released a few days ago. I'm not sure if this particular issue is fixed though so if someone can confirm.

@hallmatt
Copy link

hallmatt commented May 9, 2019

I'm on annotate v2.7.5. Running annotate seems to just annotate the routes.
Rails 6 rc1, ruby 2.5.1

Also running rake annotate -p after has the following error:

NameError: undefined local variable or method `after' for #<Rake::Application:0x00007fb587135da0>

@drwl drwl modified the milestones: v.2.7.5, v3.0.0 Jun 16, 2019
@drwl
Copy link
Collaborator

drwl commented Jun 16, 2019

Sorry for the delay everyone. This is my first time working with an open source project using the Github features like milestones for releases. I've since removed the v2.7.5 milestone and added v3.0.0.

I'll be taking a look at this for the v3 release.

drwl added a commit that referenced this issue Sep 2, 2019
In looking into #563, I realized there are gaps in test coverage. For example, `bin/annotate` doesn't have any tests. 

Tidying the spec directory to make it easier to add tests in future work.
@drwl drwl closed this as completed in #647 Sep 3, 2019
drwl added a commit that referenced this issue Sep 3, 2019
Prior to this change, `Annotate.include_models?` returned the inverse of `Annotate.include_routes?`. This made it so annotating models and routes was not possible to do together.

This PR adds an explicit `--models` flag and also adds it the option to `lib/generators/annotate/templates/auto_annotate_models.rake` with the default being set to `false`. 

Fixes #563 and undoes the bug introduced in #485.
@drwl
Copy link
Collaborator

drwl commented Sep 3, 2019

Just closing the loop for everyone, I added a fix for this issue. Will cut and publish the new gem shortly.

@ksouthworth
Copy link

Great! thanks so much

@alexventuraio
Copy link

Great @drwl, but how do we know when the update is ready? is there a way to do it within the rails app or we need to go to ruby gems to check this out manually?

@drwl
Copy link
Collaborator

drwl commented Sep 3, 2019 via email

peterfication pushed a commit to store2be/annotate_models that referenced this issue Jan 20, 2020
In looking into ctran#563, I realized there are gaps in test coverage. For example, `bin/annotate` doesn't have any tests. 

Tidying the spec directory to make it easier to add tests in future work.
peterfication pushed a commit to store2be/annotate_models that referenced this issue Jan 20, 2020
Prior to this change, `Annotate.include_models?` returned the inverse of `Annotate.include_routes?`. This made it so annotating models and routes was not possible to do together.

This PR adds an explicit `--models` flag and also adds it the option to `lib/generators/annotate/templates/auto_annotate_models.rake` with the default being set to `false`. 

Fixes ctran#563 and undoes the bug introduced in ctran#485.
vfonic pushed a commit to vfonic/annotate_models that referenced this issue May 8, 2020
In looking into ctran#563, I realized there are gaps in test coverage. For example, `bin/annotate` doesn't have any tests. 

Tidying the spec directory to make it easier to add tests in future work.
vfonic pushed a commit to vfonic/annotate_models that referenced this issue May 8, 2020
Prior to this change, `Annotate.include_models?` returned the inverse of `Annotate.include_routes?`. This made it so annotating models and routes was not possible to do together.

This PR adds an explicit `--models` flag and also adds it the option to `lib/generators/annotate/templates/auto_annotate_models.rake` with the default being set to `false`. 

Fixes ctran#563 and undoes the bug introduced in ctran#485.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.