Rails: I can't call a function in a module in /lib - what am I doing wrong?

前端 未结 9 1755
鱼传尺愫
鱼传尺愫 2021-01-31 08:08

I know I\'m doing something stupid or failing to do something intelligent - I\'m frequently guilty of both.

Here\'s an example of what\'s causing me pain:

I have

9条回答
  •  执笔经年
    2021-01-31 08:24

    You can't call a method in a Module directly. You need to include it in a class. Try this:

    >> class MyTest
    >>   include TestFunctions
    >> end
    => MyTest
    >> MyTest.new.abc
    123
    => nil
    

提交回复
热议问题