Perhaps that's only because you've become accustomed to the convention?

I'm bothered by the inconsistency:

>> User.find_by_id(10)
=> nil
>> User.find(:first, :conditions => ["id = ?", 10])
=> nil
>> User.find(10)
ActiveRecord::RecordNotFound: Couldn't find User with ID=10

IMO, this makes quite a bit more sense when looking at the rest of the API:

>> User.find(10)
nil
>> User.find!(10)
ActiveRecord::RecordNotFound: Couldn't find User with ID=10

-PJ
http://www.pjhyett.com

On 8/30/06, Rick Olson <[EMAIL PROTECTED]> wrote:
>
> -1
>
> I count on the fact that find(id) raises an exception.  If I'm looking
> up a model by id and it's not there, there's usually a problem.  The
> raises RecordNotFound exception is a convenient hook to render a 404
> page.
>
> If you really want it to return nil, why not use find_by_id ?
>
> --
> Rick Olson
> http://weblog.techno-weenie.net
> http://mephistoblog.com
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core
-~----------~----~----~----~------~----~------~--~---

Reply via email to