Skip to content

Instantly share code, notes, and snippets.

@djcp
Created July 10, 2015 14:31
Show Gist options
  • Save djcp/307466409df4be07c57b to your computer and use it in GitHub Desktop.
Save djcp/307466409df4be07c57b to your computer and use it in GitHub Desktop.
parsing URL paths deeply in the rails context
$ ./bin/rails runner parse_urls_deeply.rb
{:controller=>"videos", :action=>"index"}
{:controller=>"videos", :action=>"update", :id=>"2923e492348234981"}
[
{ method: 'GET', path: '/videos' },
{ method: 'PUT', path: '/videos/2923e492348234981' }
].each do |request|
puts Rails.application.routes.recognize_path request[:path], method: request[:method]
end
@djcp
Copy link
Author

djcp commented Jul 10, 2015

You could also write this into a class that you exercise in a rake task, which is probably how I'd ultimately do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment