Find.all Question

Hi,

I’ve heard that it’s preferred not to use Model_Name.find(:all,
:conditions => [“blah = 2”]
And that using something like Model_Name.find_by_blah(2) is better.

If that’s the case, how would I do this?

@all_apples = Apple.find(:all, :conditions => [“flavor != 1”])

Can I do something like
Apple.find_all_by_flavor(!1)

Any help on this is appreciated.

Thanks, Fred.

If flavor were a boolean field you could do

Apple.find_by_flavor(false)

On Jan 10, 2008 3:19 AM, Joe P. [email protected]
wrote:

Thanks, Fred.

Posted via http://www.ruby-forum.com/.


Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.

On 9 Jan 2008, at 16:24, Joe P. wrote:

Hi,

I’ve heard that it’s preferred not to use Model_Name.find(:all,
:conditions => [“blah = 2”]
And that using something like Model_Name.find_by_blah(2) is better.

In a complete void of information, the only better thing is
readability (and that should be Model_Name.find_all_by_blah(2))

If that’s the case, how would I do this?

@all_apples = Apple.find(:all, :conditions => [“flavor != 1”])

Can I do something like
Apple.find_all_by_flavor(!1)

You can’t. You just have to write it out in full.

Fred