Skip to content

annotate --routes changes model files #357

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

Closed
aminariana opened this issue Mar 17, 2016 · 5 comments
Closed

annotate --routes changes model files #357

aminariana opened this issue Mar 17, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@aminariana
Copy link

When I do a simple:
annotate --routes

I expect only the routes.rb file to change, not the model annotations. But they do.

My usage hasn't changed from previous versions of annotate. But going from v2.6.10 to v2.7, when I run the command, it overrides my existing model annotations with fresh ones, without the desired options such as annotating indexes that I otherwise specify in annotating models. Breaking change I think?

EDIT:

Downgrading to v2.6.10 fixes the problem.

@kamilbielawski
Copy link
Contributor

I believe the behaviour you described is like that by design.
I've just made a small PR with additional option (--ignore-models) that will let you achieve desired behaviour. However, I'm not entirely sure if that's the right approach. It would be great to hear @ctran's opinion

@aminariana
Copy link
Author

If by design, why inconsistent between two versions?

If I annotate routes, it violates my expectations to see model files modified.

@ctran ctran added the bug label May 9, 2016
@ctran ctran added this to the v2.8.0 milestone May 9, 2016
@ctran ctran self-assigned this May 9, 2016
@Hitabis
Copy link
Contributor

Hitabis commented Jul 11, 2017

Why not only annotating the routes when calling annotate --routes?
It would only be necessary to check the presence of the routes argument and the user would get the expected result. As simple as that.
This is the function causing the unexpected behavior:

def self.include_models?

Hitabis added a commit to Hitabis/annotate_models that referenced this issue Jul 11, 2017
This change is a proposed solution to ctran#357 and an alternative to the already proposed solution ctran#361.
In ctran#361 it is needed to call `annotate --routes --ignore-models` to achieve the same as in this change with only `annotate --routes`.
@ctran ctran modified the milestones: v2.7.3, v2.8.0 Jul 12, 2017
@ctran
Copy link
Owner

ctran commented Jul 12, 2017

Ah, I misread the existing behavior.

ctran pushed a commit that referenced this issue Jul 12, 2017
* 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`
@ctran ctran modified the milestones: v2.7.3, v2.7.4 Apr 21, 2018
@ctran ctran modified the milestones: v2.7.4, v.2.7.5 Jun 3, 2018
@javierguajardo
Copy link

@aminariana I've tested your issue using:

  • Rails 5.2.0
  • Ruby 2.5.1
  • Annotate 2.7.3

I ran annotate --routes and only the config/routes.rb file was changed. I believe this problem has been patched with 2.7.3.

Regards.

@ctran ctran closed this as completed Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants