Skip to content

Instantly share code, notes, and snippets.

@gmaliar
Created January 28, 2016 13:09
Show Gist options
  • Save gmaliar/b539a08d30bb567bb5e7 to your computer and use it in GitHub Desktop.
Save gmaliar/b539a08d30bb567bb5e7 to your computer and use it in GitHub Desktop.
# routes.rb
namespace :api do
Dir[Rails.root.join("app", "controllers", "api", "*_controller.rb")].map { |file| file.match(/app\/controllers\/api\/([[:alpha:]]+)_controller\.rb/)[1].pluralize }.each |ctrl|
resources ctrl.to_sym
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment