R
Ralph Shnelvar
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?
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?