Strange has_many array problem


#1

I have a class that has_many :visits, I want to search through the
visits to get only ones that are committed:
I thought it would be as easy as:

visits.find_all do |visit|
visit.coming?
end

but this always returns the entire list of visits. The only way to
get it to work is to put the visits into a new array first:

Array.new(visits).find_all do |visit|
visit.coming?
end

Can someone explain this to me?

-John


John S.
Computing Staff - Webmaster
Kavli Institute for Theoretical Physics
University of California, Santa Barbara
removed_email_address@domain.invalid
(805) 893-6307


#2

Hi John,

Using your example:

visits.each do |visit|
visit.coming?
end

HTH
Trevor

Trevor S.
http://somethinglearned.com