From: Ralph Shnelvar Date: 2009-11-21T04:42:39+09:00 Subject: Re: Something like puts >> From: Ralph Shnelvar [mailto:ralphs@dos32.com] >> Newbie question: >> >> I need/want a function like puts ... that is, a function known >> globally. >> >> I have read the Pickaxe section on mixins and >> http://www.ruby-forum.com/topic/68638 and I'm going nuts. >> >> Specifically I am trying to do >> >> >> module ApplicationHelper >> puts "Hearyee ApplicationHelper" >> >> def at_file_line_msg(file, line, msg) >> file + " @ " + line.to_s + ":" + msg >> end >> >> puts at_file_line_msg(__FILE__, __LINE__, "") >> end >> >> The >> puts at_file_line_msg(__FILE__, __LINE__, "") >> generates the right output. >> >> When I attempt to mixin ApplicationHelper into a classand then attempt >> to call >> puts at_file_line_msg(__FILE__, __LINE__, "") >> I get a "module not defined" error. >> >> >> I think this has something to do with Modules not mixing in, uh, class >> methods. Frankly, I'm not following the arguments. >> >> >> So ... what is the right way to create a function like puts that is >> known everywhere? WH> Maybe I'm missing something, but I think what you want is to just WH> define it in the default global scope: Duh! That works! God, I'm stupid. Thanks!!!