On Fri, 7 Apr 2006, sas sas wrote:

> thanks for the advice, but I'm stuck with something even more trivial
>
> I tried adding the following in C:\ruby\lib\ruby\1.8\cgi\session.rb
>
>    def sayHello
>      "hello"
>    end
>
> and then in a view
>
> <%= session.sayHello %>
>
> but then I get the following error
>
> Showing app/views/resolucion/list.rhtml where line #19 raised:
>
> undefined method `sayHello' for #<CGI::Session:0x38f6bd0>
>
> Seems like my changes are completely ignored...
>
> any idea???

only one of three things can be happening

   - you are not using that session.rb, another one exists on your system

   - you are putting you edit in the wrong place in that file, show us the
     actual code, not a snippet

   - you are not restarting your server or otherwise loading the code

you can easily test this from the command line, which will be a whole lot
easier than doing from within rails.  for example

   ruby -r cgi -r cgi/session -e' s = CGI::Session.new(CGI.new); p s.sayHello ' < /dev/null

when this works you will have made the edit in the right place.

btw.  it's a horrible idea to change the core lib files in that way.  ruby's
open classes provides a method about 1000 times easier and safer than that to
make changes to core classes:


   jib:~ > cat a.rb
   class CGI
     class Session
       def say_hello
         puts 'hi'
       end
     end
   end


   jib:~ > ruby -r cgi -r cgi/session -r ./a.rb -e' s = CGI::Session.new(CGI.new); s.say_hello ' < /dev/null
   hi

in otherwords you do not need to, nor should you, edit session.rb to make this
change.

hth.

-a
-- 
be kind whenever possible... it is always possible.
- h.h. the 14th dali lama