Forum: Ruby Newbie - Problem Two - Ruby and Form Variables, re-loading l

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.
3ec3861d1ab1717293c8c4868fe7a355?d=identicon&s=25 unknown (Guest)
on 2006-01-04 23:05
(Received via mailing list)
I am attempting to copy a PHP project I did in Ruby.

I basically have a search form / web page, which looks for matching
records and displays them prior to the search box form.

I reload the page with

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST" name =
"Nextrec" >

I then use the isset function to test whether any records have been
displayed and skip the display and go straight to the form.  I know
this could have been achieved with javascript, but that was a no no.

I have discovered require cgi and it sems to give me all the info I
need, but how do I replicate the form button action re-loading the page
with all the variables in tact.

Thanks

Richard
036a1b88dafaab8ffd73a8b0a74b5b38?d=identicon&s=25 Edward Faulkner (Guest)
on 2006-01-05 17:44
(Received via mailing list)
On Thu, Jan 05, 2006 at 07:03:34AM +0900, page77.office@googlemail.com
wrote:
> <FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST" name =
> "Nextrec" >

If I remember my PHP correctly, $_SERVER['PHP_SELF'] is simply the
name of the currently executing file.  The Ruby equivalent is
__FILE__.

regards,
Ed
Ace7fa5337acbdf5897a6fc035897580?d=identicon&s=25 J. Ryan Sobol (Guest)
on 2006-01-05 17:44
(Received via mailing list)
Actually, you'll also need to call basename().  So,

basename($_SERVER['PHP_SELF'] )  == __FILE__

~ ryan ~
3ec3861d1ab1717293c8c4868fe7a355?d=identicon&s=25 mosscliffe (Guest)
on 2006-01-05 23:45
(Received via mailing list)
Thanks for the replies, and yes PHP_SELF is the name of the running
current page.

I am sorry to be stupid, but how do I get the form action to execute
basename(__FILE__) as I did with:

<FORM action="<?php print $_SERVER['PHP_SELF'];?>" method="POST"

Thanks again

Richard
Ace7fa5337acbdf5897a6fc035897580?d=identicon&s=25 J. Ryan Sobol (Guest)
on 2006-01-06 01:25
(Received via mailing list)
basename() is a PHP function, not a Ruby one.

~ ryan ~
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-01-06 02:28
(Received via mailing list)
On Jan 5, 2006, at 6:22 PM, J. Ryan Sobol wrote:

> basename() is a PHP function, not a Ruby one.

$ ri -T File::basename
--------------------------------------------------------- File::basename
      File.basename(file_name [, suffix] ) -> base_name
------------------------------------------------------------------------
      Returns the last component of the filename given in file_name,
      which must be formed using forward slashes (``/'') regardless of
      the separator used on the local file system. If suffix is given
      and present at the end of file_name, it is removed.

         File.basename("/home/gumby/work/ruby.rb")          #=>
"ruby.rb"
         File.basename("/home/gumby/work/ruby.rb", ".rb")   #=> "ruby"


James Edward Gray II
Ace7fa5337acbdf5897a6fc035897580?d=identicon&s=25 J. Ryan Sobol (Guest)
on 2006-01-06 03:52
(Received via mailing list)
Thanks James.  :)

~ ryan ~
This topic is locked and can not be replied to.