[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Colin Law
2009/6/26 Frederick Cheung : > > > On Jun 26, 9:10 pm, Philip Hallstrom wrote: >> >> Not quite... it looks like an array, but it's not.  Otherwise you >> wouldn't be able to say "p.comments.create()" or >> "p.comments.find(:conditions => )" but you can. >> >> The code above works because

[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Frederick Cheung
On Jun 26, 9:10 pm, Philip Hallstrom wrote: > > Not quite... it looks like an array, but it's not.  Otherwise you   > wouldn't be able to say "p.comments.create()" or   > "p.comments.find(:conditions => )" but you can. > > The code above works because foobar is defined as class method, n

[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Philip Hallstrom
>> >> In the code below, p.comments.foobar calls #foobar on every comment. >> Is there a way to call #foobar only on the comments that belong to >> post "p"? >> >> >> class Comment < ActiveRecord::Base >> belongs_to :post >> >> def self.foobar; end >> end >> >> class Post <

[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Nick Hoffman
On Jun 26, 3:51 pm, Colin Law wrote: > 2009/6/26 Nick Hoffman : > > In the code below, p.comments.foobar calls #foobar on every comment. > > Is there a way to call #foobar only on the comments that belong to > > post "p"? > > > > > class Comment < ActiveRecord::Base > >  belo

[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Colin Law
2009/6/26 Nick Hoffman : > > In the code below, p.comments.foobar calls #foobar on every comment. > Is there a way to call #foobar only on the comments that belong to > post "p"? > > > class Comment < ActiveRecord::Base >  belongs_to :post > >  def self.foobar; end > end > > c