Hi, I''d like to catch certain type of URLs that follow the pattern "http://server.com/map/http://www.another.com/url/with.php?possible=arguments" and map that to a controller which gets *whatever comes after "/map/" as a single variable. I already tried the following mapping: map.connect ''/map/*all'', :controller => ''urlmapper'', :action => ''test'', :all => /.*/ and in the controller then concatenating the resulting "all" array into a single string, but that only works when there''s no URL request parameters ("?foo=bar"). What would be the "Rails way" to do what I''m describing here? And thanks for "listening" :) -- Posted via http://www.ruby-forum.com/.
On 12/9/05, Lasse Koskela <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> and in the controller then concatenating the resulting "all" array into > a single string, but that only works when there''s no URL request > parameters ("?foo=bar").You need to URL encode the ''?'' if you don''t want it to be picked up as a querystring separator. -- Regards, John Wilger http://johnwilger.com ----------- Alice came to a fork in the road. "Which road do I take?" she asked. "Where do you want to go?" responded the Cheshire cat. "I don''t know," Alice answered. "Then," said the cat, "it doesn''t matter." - Lewis Carrol, Alice in Wonderland
johnwilger wrote:> On 12/9/05, Lasse Koskela <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> and in the controller then concatenating the resulting "all" array into >> a single string, but that only works when there''s no URL request >> parameters ("?foo=bar"). > > You need to URL encode the ''?'' if you don''t want it to be picked up as > a querystring separator.Thanks John. I was aware of the query string being treated as a query string. I''m just wondering if someone somewhere has already implemented some kind of a utility/tweak to "fake" the path and query string into a single string. Can we access the original request URL from a controller? -Lasse- -- Posted via http://www.ruby-forum.com/.
Lasse wrote:> Can we access the original request URL from a controller?Sorry for asking something that''s in the RDocs... Yeah, there''s "request.request_uri" which returns the full path including query string. I suppose I could just parse that to pick up the URL from the end. -- Posted via http://www.ruby-forum.com/.
No need to parse. A route like: map.connect ''serve/*commands'', :controller => ''serve'' Will yield an array called ''commands'' in your controller. :) - Rabbit --- On 12/9/05, Lasse <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Lasse wrote: > > Can we access the original request URL from a controller? > > Sorry for asking something that''s in the RDocs... Yeah, there''s > "request.request_uri" which returns the full path including query > string. I suppose I could just parse that to pick up the URL from the > end. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I should note that ''commands'' is available in params. (params[:commands]) - Rabbit --- On 12/12/05, Rabbit <rabbitblue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No need to parse. > > A route like: > map.connect ''serve/*commands'', :controller => ''serve'' > > Will yield an array called ''commands'' in your controller. :) > > - Rabbit > > --- > > On 12/9/05, Lasse <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> <lasse.koskela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Lasse wrote: > > > Can we access the original request URL from a controller? > > > > Sorry for asking something that''s in the RDocs... Yeah, there''s > > "request.request_uri" which returns the full path including query > > string. I suppose I could just parse that to pick up the URL from the > > end. > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >