Created
July 10, 2015 14:31
-
-
Save djcp/307466409df4be07c57b to your computer and use it in GitHub Desktop.
parsing URL paths deeply in the rails context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./bin/rails runner parse_urls_deeply.rb | |
{:controller=>"videos", :action=>"index"} | |
{:controller=>"videos", :action=>"update", :id=>"2923e492348234981"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ method: 'GET', path: '/videos' }, | |
{ method: 'PUT', path: '/videos/2923e492348234981' } | |
].each do |request| | |
puts Rails.application.routes.recognize_path request[:path], method: request[:method] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also write this into a class that you exercise in a rake task, which is probably how I'd ultimately do this.