Skip to content

Instantly share code, notes, and snippets.

@overdrivemachines
Created October 14, 2025 06:14
Show Gist options
  • Save overdrivemachines/18ab18a986f1db4ec1fe6fbfb37b90ba to your computer and use it in GitHub Desktop.
Save overdrivemachines/18ab18a986f1db4ec1fe6fbfb37b90ba to your computer and use it in GitHub Desktop.
routes.rake
task routes: :environment do
Rails.application.eager_load!
models = ApplicationRecord.descendants.collect(&:name).join("|").downcase
controllers = ApplicationController.descendants.collect(&:name)
controllers = (controllers.map { |controller| controller[0..-11].downcase }).join("|")
if models
puts `bundle exec rails routes -g "#{models}|#{controllers}"`
else
puts `bundle exec rails routes -g "#{controllers}"`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment