Dynamic find methods Vs conditional statements

Posted by piemesons on Stack Overflow See other posts from Stack Overflow or by piemesons
Published on 2010-05-23T19:41:09Z Indexed on 2010/05/23 19:50 UTC
Read the original article Hit count: 535

Student.find(:all, :conditions => [‘name = ? and status = ?’ ‘mohit’, 1])

Vs

Student.find_all_by_name_and_status(‘mohit’, 1)

Both the queries will result the same set of row but first one is preferable cause in the second way there will be exception generated method_missing and then rails will try to relate it as dynamic method. if fine then result set to returned. Can any body explain me this in a good manner. What exactly is happening behind the screen. Please correct me if i am wrong.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about best-practices