# Private methods fail when called from CGI

**URL:** <https://www.ruby-forum.com/t/private-methods-fail-when-called-from-cgi/226030>\
**Category:** Ruby\
**Created:** [October 15, 2008, 9:09pm UTC](https://www.ruby-forum.com/t/private-methods-fail-when-called-from-cgi/226030 "2008-10-15T21:09:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevedogers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9dc877/32.png) [@stevedogers](https://www.ruby-forum.com/u/stevedogers)\
**Post date:** [October 15, 2008, 9:09pm UTC](https://www.ruby-forum.com/t/private-methods-fail-when-called-from-cgi/226030/1 "2008-10-15T21:09:03Z")

</div>

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”)+  
@removed\_email\_address@domain.invalid+  
“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
