From: Calvin Bornhofen Date: 2013-01-08T07:31:00+09:00 Subject: Re: Newbie question: Referencing a class inside another class Hello, if you have required the content of lib/pkg/sample.rb into app/models/caller.rb, you can simply reference the class SampleError by its name. It is defined in the global namespace, unless in sample.rb the classes are in another module (in that case you have to proceed as Henry told you). To require the content, just use one of the functions in the require family in the top of your file caller.rb. This would look something like the following: require_relative '../../lib/pkg/sample.rb' Note: require_relative requires the file relative from the file it's written in, unlike require, which looks through a specified set of directories ($LOAD_PATH) and takes the file from there. regards, Calvin On 07.01.2013 23:04, brinda M. wrote: > Thanks for the reply. > However I should have been clear about what I meant. Sorry! The class is > defined as follows: > > class SampleError > end > > class Sample > end > > They are defined in file lib/pkg/sample.rb. > > How do I reference SampleError from app/models/caller.rb since > SampleError is defined inside sample.rb? > Thanks!