What I want to do is take a url string (from a file,db,form field,…)
and turn it into a hash.
For example:
string = ‘proto://host.com/posts/show/10?user=joe’
url_to_hash(string) #=> {:controller => ‘posts’, :action => ‘show’, :id
=> 10, :user => ‘joe’}
Does rails have anything like this already built in, or a simple way of
doing this?
If not:
How does rails take the url and create the params[] hash?
On line 458 in routing.rb in the rails source there is a line
“hash = recognize_path(path)”
which looks like it MIGHT be doing the same thing that I want. I just
can’t figure out how to access that function to test this.