From: "warrene33@..." Date: 2007-06-22T21:25:02+09:00 Subject: Re: newbie question - undefined method `replace_session_timeout' for main:Object (NoMethodError) On Jun 21, 10:58 pm, Morton Goldberg wrote: > On Jun 21, 2007, at 10:35 PM, warren...@gmail.com wrote: > > > > > #script for changing the sessionState timeout to 30 minutes > > > f = File.open('C:\Inetpub\wwwroot\GT\web.config', 'r+') > > f.each do |line| > > if /sessionState/ =~line > > offset=line.length > > line=replace_session_timeout line > > f.seek(-offset, IO::SEEK_CUR) > > f.print line > > end > > end > > f.close > > > def replace_session_timeout line > > int = / > spacer = line[0..int-1] > > result=line.replace spacer + "\r\n" > > end > > > When I run this script I get the following error: > >> ruby GT_SessionTimeout_1.rb > > GT_SessionTimeout_1.rb:7: undefined method `replace_session_timeout' > > for main:Object (NoMethodError) > > from GT_SessionTimeout_1.rb:4:in `each' > > from GT_SessionTimeout_1.rb:4 > >> Exit code: 1 > > > I guess there is something wrong with my method call, but it looks > > syntactically correct to me. > > The Ruby interpreter needs to see the definition of > replace_session_timeout before it is called for the first time. Just > move the definition above the body of the script. > > Regards, Morton Wow. That simple. Thanks Warren