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

decide when run rake or rails routes. #985

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ when using `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
# path :geometry line_string, 4326
```

Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rake routes`.
Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rake/rails routes`.


## Upgrading to 3.X and annotate models not working?
Expand Down Expand Up @@ -217,7 +217,7 @@ you can do so with a simple environment variable, instead of editing the
If --w option is used, the same text will be used as opening and closing
--wo, --wrapper-open STR Annotation wrapper opening.
--wc, --wrapper-close STR Annotation wrapper closing
-r, --routes Annotate routes.rb with the output of 'rake routes'
-r, --routes Annotate routes.rb with the output of 'rake/rails routes'
--models Annotate ActiveRecord models
-a, --active-admin Annotate active_admin models
-v, --version Show the current version of this gem
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/annotate_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#
#
# Prepends the output of "rake routes" to the top of your routes.rb file.
# Prepends the output of "rake/rails routes" to the top of your routes.rb file.
# Yes, it's simple but I'm thick and often need a reminder of what my routes
# mean.
#
Expand Down
4 changes: 3 additions & 1 deletion lib/annotate/annotate_routes/header_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'active_record'
require_relative './helpers'

module AnnotateRoutes
Expand All @@ -16,7 +17,8 @@ def generate(options = {})
private

def routes_map(options)
result = `rake routes`.chomp("\n").split(/\n/, -1)
command = ActiveRecord.version.to_s.first.to_i > 5 ? `rails routes` : `rake routes`
result = command.chomp("\n").split(/\n/, -1)

# In old versions of Rake, the first line of output was the cwd. Not so
# much in newer ones. We ditch that line if it exists, and if not, we
Expand Down
2 changes: 1 addition & 1 deletion lib/annotate/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def add_options_to_parser(option_parser) # rubocop:disable Metrics/MethodLength,

option_parser.on('-r',
'--routes',
"Annotate routes.rb with the output of 'rake routes'") do
"Annotate routes.rb with the output of 'rake/rails routes'") do
env['routes'] = 'true'
end

Expand Down