ActiveRecord types of find

Hi, If I do the following ActiveRecord query AccountType.find_by_active(true).collect{|at| [at.name,at.id]} I get the error undefined method `collect' for #<AccountType:0x459fb10>

However if I do AccountType.find(:all,:conditions=>["active= ? ", true]).collect{|at| [at.name,at.id]}

then everything is fine.

Why does the find_by_active(true) method work differently from the longhand version?

Cheers George

Hi,

find_by_something returns first record matched by default.

What you are loking for is find_all_by_something that returns an array.

Best, H.

Thanks for that.

That makes sense

Cheers George