I’m trying to create a method on a model (Note) that finds a subset of
records, but banging my head against a brick wall. The code so far:
find(:all, :conditions => [“notes.created_at <= ?”,
Ultimately I want to be able to use @person.notes.can_be_viewed, but
I’m getting an “undefined local variable or method `person’ for
#Class:0x8ed10b8” error. This isn’t surprising - the can_be_viewed
method is a class method, so has no way of accessing
person.cutoff_date in the finder.
All I’m really trying to say here is:
- A person has a cutoff date (this can vary according to who the
logged-in user is, but that’s irrelevant, although the cutoff_date
method generates some SQL).
- Notes can be viewed if they are created before their person’s
I’d appreciate any thoughts on this.