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

Unable to annotate routes at the bottom while it works correctly for Models #761

Closed
sandip-mane opened this issue Feb 23, 2020 · 1 comment · Fixed by #803
Closed

Unable to annotate routes at the bottom while it works correctly for Models #761

sandip-mane opened this issue Feb 23, 2020 · 1 comment · Fixed by #803

Comments

@sandip-mane
Copy link

Unable to annotate_routes at the bottom of the file. This is working for models as expected.

Commands

$ rails annotate_routes

Configuration

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(
      'active_admin'                => 'false',
      'additional_file_patterns'    => [],
      'routes'                      => 'true',
      'models'                      => 'true',
      'position_in_routes'          => 'after',
      'position_in_class'           => 'after',
      'position_in_test'            => 'after',
      'position_in_fixture'         => 'after',
      'position_in_factory'         => 'after',

Versions

  • 3.1.0
  • 6.0.2.1
  • 2.6.5
@javawizard
Copy link
Contributor

javawizard commented May 9, 2020

Ditto - this is happening for me as well - route annotations are being added at the top by bundle exec rake annotate_routes, even with position_in_routes set to after in the Rake task. However, if I do bundle exec annotate -p after -r, annotations are placed at the bottom of my routes.rb as expected.

My lib/tasks/auto_annotate_models.rake:

# 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(
      'active_admin'                => 'false',
      'additional_file_patterns'    => [],
      'routes'                      => 'true',
      'models'                      => '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'               => '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,bigint,boolean',
      'hide_default_column_types'   => 'json,jsonb,hstore',
      'skip_on_db_migrate'          => 'false',
      'format_bare'                 => 'true',
      'format_rdoc'                 => 'false',
      'format_yard'                 => 'false',
      'format_markdown'             => 'false',
      'sort'                        => 'false',
      'force'                       => 'false',
      'frozen'                      => 'false',
      'classified_sort'             => 'true',
      'trace'                       => 'false',
      'wrapper_open'                => nil,
      'wrapper_close'               => nil,
      'with_comment'                => 'true'
    )
  end

  Annotate.load_tasks
end

@drwl drwl closed this as completed in #803 May 18, 2020
drwl pushed a commit that referenced this issue May 18, 2020
Make `annotate_routes` depend on `set_annotation_options` just as `annotate_models` does.

Fixes #761.
ocarta-l pushed a commit to ocarta-l/annotate_models that referenced this issue Jun 18, 2021
Make `annotate_routes` depend on `set_annotation_options` just as `annotate_models` does.

Fixes ctran#761.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants