Forum: Ruby on Rails Query String in routes.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jon A. Lambert (Guest)
on 2006-01-24 05:10
(Received via mailing list)
Is there any way to access the query string full request uri in
routes.rb?

I'd like to route requests for those going after my old application urls
to
my new rails application urls.

The old app used
/wiki.cgi?PageName
The rails app uses
/wiki/show/PageName

Like...
  map.connect 'wiki.cgi', :controller => "wiki", :action => "show", :id
=>
ENV['QUERY_STRING']

ENV doesn't contain any CGI bits at all at the point routes.rb is
called.

env is invalid
request is invalid
params is invalid

What variables ARE valid at this point and do any of them contain what I
want?

No Apache solutions please.

Thanks.

--
J. Lambert
joey__ (Guest)
on 2006-01-24 09:13
Jon A. Lambert wrote:
> Is there any way to access the query string full request uri in
> routes.rb?
>
> I'd like to route requests for those going after my old application urls
> to
> my new rails application urls.
>
> The old app used
> /wiki.cgi?PageName
> The rails app uses
> /wiki/show/PageName
>
> Like...
>   map.connect 'wiki.cgi', :controller => "wiki", :action => "show", :id

> J. Lambert

map.connect 'wiki.cgi?:id', :controller => "wiki", :action => "show",
:id => :id

The above should work, but it will still show wiki.cgi?PageName in the
browser. You could add an action to your wiki controller to redirect:
  def redirect
    redirect_to :controller => "wiki", :action => "show", :id =>
params[:id]
  end

The the route would be:


map.connect 'wiki.cgi?:id', :controller => "wiki", :action =>
"redirect", :id => :id
This topic is locked and can not be replied to.