Hi --
Alex- thanks for that tip, that fills in some big gaps. However, I ran into one snafu:
Alex Wayne wrote:
Cw K. wrote:
While it is beautifully easy to do john.posts and get *all* of John's posts, what I almost always need to do is get john.posts(not_deleted and post_date=today) or something like that.
You can define a :conditions attribute when you find associated objects, or on the association call itself.
john.posts.find(:all, :conditions => ['not_deleted = ?', true])
When I try this I get an error: ArgumentError: wrong number of arguments (2 for 1)
Whoops, I didn't spot that problem when I advised about not bothering with the " = ?', true" part
The method below however works fine
Or even better
class User < ActiveRecord::Base has_many :posts, :conditions => ['not_deleted = ?', true]
Now I'll give my advice again, hopefully in a working context
has_many :posts, :conditions => "not_deleted"
No need to compare it to true.
David