Something has really been perplexing to me when trying to use Ruby CGI.

I have a set of methods that render CGI screens just fine from a
dispatcher in the main CGI program that receives requests.  But when I
want to add a private helper method within the same Class collection,
any call to that private function fails.

Something like this... (look for the show_dummy() function below.  Why
does attempting to call show_dummy() within  CGI::escapeHTML (or any
other place in this CGI structure, fail?

The really big picture I'm trying to understand is how typical RUBY CGI
programs are constructed to run a dispatcher and potentially run
additional private programs within each View that gets painted.
(Please... the answer I'm looking for is not... FORGET CGI, USE RAILS...
that is too complicated for infrastructure constraints I'm programming
within).

What is doubly confusing for me is why the ENV.collect() method runs
just fine, yet the show_dummy() private method will not work at all in
this class.

class ModeView

   def initialize(cgi_object, version, cookie, state)
     @cgi = cgi_object
     @cookie = cookie
     @state = state
     @FCP_app_banner  = 'Control Panel ' + version
     @FCP_page_banner = 'Operation : '
   end

   # -------------------- One of several CGI "Views"
-----------------------
   def HPC_StatusQuery
   # Polls the HPC Linux Cluster to determine what jobs are pending
   @cgi.out {
      @cgi.html {
         @cgi.head { @cgi.title {@FCP_app_banner}} +
         @cgi.body {
            @cgi.h3 {@FCP_page_banner +'HPC Status Query'} +
            @cgi.hr +
            @cgi.form() do
               "JOB ID: " + @cgi.text_field("hpc_job_id", "", 60, 160)+
@cgi.br+
               @cgi.reset("RESET")+"  "+
               @cgi.submit("RUN")+
               @cgi.br+@cgi.br+
               "SELECT NEXT OPERATION:"+
               @cgi.br+
               @cgi.popup_menu("fcp_mode",
                              "HPC Status Query",
                              "Build TTP Composite File",
                              "TTP Membership Vector",
                              "TTP View Tracefile Generation",
                              "Single Parameter Mining",
                              "Multiple Parameter Mining",
                              "DISK Maintenance")
            end +
            @cgi.hr +
            @cgi.p  {'Debug Only:'}+
            @cgi.pre() do
               CGI::escapeHTML(
                  "params: " + @cgi.params.inspect + "\n"+
                  "cookies: " + @cgi.cookies.inspect + "\n" +
                   show_dummy() +
                  "ENV" + ENV.collect() do |key, value|
                    key + " --> " + value + "\n"
                  end.join("")
               )
            end
         }
      }
   }
   end

   # ------------------------ dummy helper method
-------------------------
   private
   def show_dummy()
     ...
   end
end
-- 
Posted via http://www.ruby-forum.com/.