Forum: Ruby pass parameters on a redirct

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.
JoeyP (Guest)
on 2007-04-03 22:05
(Received via mailing list)
The client presses a submit button.

The path goes to a .cgi script that gathers the form params.

How can I pass those parameter onto another page?

EX.
#!/usr/bin/ruby
# *-ruby-*-
require 'cgi'
cgi = CGI.new

  def redirect( new_page )
    print "Location:#{new_page}\n\n"
  end

all_params  = cgi.params


if ( !all_params.include? 'select')
redirect('selectPage.rhtml')
else
redirect('genPage.rhtml')
end

How do I pass 'all_params' to page I'm redirecting to?

Thanks
Vlad C. (Guest)
on 2007-04-03 22:25
(Received via mailing list)
You must save them in the user's session. Rails has this it's called the
flash, temporary storage between two pages.

I were you I would really consider ruby on rails for web programming,
it's
not a steep learning curve and you solve your problems with much fewer
lines of code.

vlad
JoeyP (Guest)
on 2007-04-03 22:35
(Received via mailing list)
On Apr 3, 2:19 pm, Vlad C. <removed_email_address@domain.invalid> wrote:
>
> > require 'cgi'
> > else
> > redirect('genPage.rhtml')
> > end
>
> > How do I pass 'all_params' to page I'm redirecting to?
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -

Thanks a bunch. I thought that that was what I was looking at.
unknown (Guest)
on 2007-04-03 22:42
(Received via mailing list)
On Wed, 4 Apr 2007, JoeyP wrote:

> cgi = CGI.new
> else
> redirect('genPage.rhtml')
> end
>
> How do I pass 'all_params' to page I'm redirecting to?
>
> Thanks


   harp:~ > cat a.rb
   require 'cgi'

   class Hash
     def query
       map{|k,v| [CGI.escape(k), CGI.escape(v)].join('=')}.join('&')
     end
   end

   cgi = CGI.new

  def redirect( new_page , params)
    print "Location:#{ new_page }?#{ params.query }\n\n"
  end

   if ( !all_params.include? 'select')
     redirect('selectPage.rhtml', cgi.params)
   else
     redirect('genPage.rhtml', cgi.params)
   end

-a
JoeyP (Guest)
on 2007-04-03 23:22
(Received via mailing list)
On Apr 3, 2:41 pm, removed_email_address@domain.invalid wrote:
> > require 'cgi'
> > else
>    class Hash
>
>
> - Show quoted text -

I'm not familiar with 'harp:~ > cat a.rb '
can you expand?

Thanks
unknown (Guest)
on 2007-04-03 23:36
(Received via mailing list)
On Wed, 4 Apr 2007, JoeyP wrote:

>>
>> -a
>> --
>> be kind whenever possible... it is always possible.
>> - the dalai lama- Hide quoted text -
>>
>> - Show quoted text -
>
> I'm not familiar with 'harp:~ > cat a.rb '
> can you expand?

??

that's just my prompt

-a
This topic is locked and can not be replied to.