From: "David A. Black" Date: 2008-04-07T18:12:57+09:00 Subject: Re: Calling class method from instance method Hi -- On Mon, 7 Apr 2008, Yu-shan Fung wrote: > Pretty dumb question -- how do I call a class method from inside an > instance method (of the same class)? > > The use case I have is that in an activerecord model class, I would like > to define an instance method which calls find_by_sql. > > I have tried and found that this works: > self.class.find_by_sql > > > But this seems pretty verbose for something so obvious. You need the 'self.' part because class is a keyword. It's a bit verbose but something's got to give :-) David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!