How do I make module methods available to a constant Proc variable? (Ruby) -
this in application helper:
def call_me "blah" end p = proc.new { call_me } def test_me p.call end
if in view:
<%= test_me %>
i error saying call_me undefined method.
how proc able call call_me? require doesn't it. prefixing applicationhelper::call_me doesn't either. :(
this works, don't since test_me called lots of times , in reality there many many more procs:
def test_me p = proc.new { call_me } p.call end
it should work in ruby 1.9.2, in earlier versions can pass helper argument proc:
p = proc.new { |helper| helper.call_me } def test_me p.call self end
since call_me
instance method on helper, need invoke instance.
Comments
Post a Comment