[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Sijo kg wrote: > It is not a difficult thing to grasp Just an example Suppose you > have a class Fruit.Now an apple and an orange are instances of the class > Fruit. So in Ruby it can be created like > > apple = Fruit.new or > orange = Fruit.new > > > Thousands of other examples.Y

[Rails] Re: Custom class

2009-10-06 Thread Sijo kg
Hi Pål Bergström > That was great. Thank you. Still not sure about instance and what it > means. It is not a difficult thing to grasp Just an example Suppose you have a class Fruit.Now an apple and an orange are instances of the class Fruit. So in Ruby it can be created like apple = F

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Sijo kg wrote: > http://railstips.org/2009/5/11/class-and-instance-methods-in-ruby > That was great. Thank you. Still not sure about instance and what it means. I've encountered a lot in my Rails life but one of those things that doesn't stick. Probably why I'm a web designer and developer s

[Rails] Re: Custom class

2009-10-06 Thread Sijo kg
Hi > Thanks. I don't fully understand but it works. > > This means you don't need to require it (?) No require needed .And to get a good understanding of class and instance methods in Ruby read http://railstips.org/2009/5/11/class-and-instance-methods-in-ruby Sijo -- Posted via ht

[Rails] Re: Custom class

2009-10-06 Thread Colin Law
2009/10/6 Pål Bergström : > > Colin Law wrote: >> 2009/10/6 Pål Bergström : > >> 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 > > Thanks. I don't fully understand but it works. > > This means

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Colin Law wrote: > 2009/10/6 Pål Bergström : > 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 Thanks. I don't fully understand but it works. This means you don't need to require it (?) -- Posted

[Rails] Re: Custom class

2009-10-06 Thread Colin Law
2009/10/6 Pål Bergström : > > 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 w

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Pål Bergström wrote: > I see. I have another solution, a custom Crypto-class, in another app > similar to this without a require (as I can see now, was a while ago) > and that works. It's also in /lib. Can't understan why that works and > now it doesn't. > > I thought that custom classes in /

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Leonardo Mateo wrote: > 2009/10/6 Pål Bergström : >>> >>> -- >>> Leonardo Mateo. >>> There's no place like ~ >> >> I can't make it work. I've put in the lib directory. Do I need to make a >> require or something? I get an error "private method `test' called for > Of course you have to require them

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
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 -- Posted via http://www.ruby-forum.com/. --~--~-~-

[Rails] Re: Custom class

2009-10-06 Thread Leonardo Mateo
2009/10/6 Pål Bergström : > > Leonardo Mateo wrote: >> 2009/10/6 P�l Bergstr�m : >>> >>> Where do I put a custom class? >> It depends on what is it's purpose but, usually, you'll put them on >> your models directory. >> >>> How do I use it? >> Just like you use every class. >> >> -- >> Leonardo Ma

[Rails] Re: Custom class

2009-10-06 Thread Sijo kg
Hi Pål Bergström Can you paste the code? Sijo -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrai

[Rails] Re: Custom class

2009-10-06 Thread Pål Bergström
Leonardo Mateo wrote: > 2009/10/6 P�l Bergstr�m : >> >> Where do I put a custom class? > It depends on what is it's purpose but, usually, you'll put them on > your models directory. > >> How do I use it? > Just like you use every class. > > -- > Leonardo Mateo. > There's no place like ~ I can't

[Rails] Re: Custom class

2009-10-06 Thread Leonardo Mateo
2009/10/6 Pål Bergström : > > Where do I put a custom class? It depends on what is it's purpose but, usually, you'll put them on your models directory. > How do I use it? Just like you use every class. -- Leonardo Mateo. There's no place like ~ --~--~-~--~~~---~--~-