Re: Custom class

Colin Law
Tue, 06 Oct 2009 10:04:09 -0000

2009/10/6 Pål Bergström
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:
>
> Sijo kg wrote:
>> Hi Pål Bergström
>>
>>   Can you paste the code?
>>
>> Sijo
>
> It''s just a test code. In the file /lib/random.rb I have:
>
> class Random
>
>  def test
>    "test"
>  end
>
> end
>
> In the controller I try to call:
>
> @test = Random.test

If you want to call it like that you must make test a class method
rather than an instance method, so it must be
def self.test
..

Colin

> --
> Posted via http://www.ruby-forum.com/.
>
> >
>