Active Resource and nil

0 views
Skip to first unread message

Henry Maddocks

unread,
Apr 30, 2008, 11:02:41 PM4/30/08
to WellR...@googlegroups.com
I have an ActiveResource call similar to below

@user = User.find(:first, :from => :email, :params => {:email =>
'foo@bar'})

If the find returns nil what is supposed to happen? I'd really like
to get nil to the caller. What's best practice in this case?

Henry

Mark Rickerby

unread,
Apr 30, 2008, 11:18:48 PM4/30/08
to WellR...@googlegroups.com

Henry Maddocks

unread,
Apr 30, 2008, 11:29:00 PM4/30/08
to WellR...@googlegroups.com

On 1/05/2008, at 3:18 PM, Mark Rickerby wrote:

>
> Is this what you mean?

No.

Orion Edwards

unread,
Apr 30, 2008, 11:34:31 PM4/30/08
to WellR...@googlegroups.com
Wow, activeresource has really changed since I last looked (before they
pulled it from the 1.2 release)

As far as I can tell from reading (don't have time to mock it up sorry), if
it can't find anything, The server is meant to return a 404 error, which
activeresource interprets as "throw a ResourceNotFound exception"

If that is the case you would have to rescue/return nil wouldn't you?

Henry Maddocks

unread,
May 1, 2008, 12:02:30 AM5/1/08
to WellR...@googlegroups.com

On 1/05/2008, at 3:34 PM, Orion Edwards wrote:

>
> Wow, activeresource has really changed since I last looked (before
> they
> pulled it from the 1.2 release)
>
> As far as I can tell from reading (don't have time to mock it up
> sorry), if
> it can't find anything, The server is meant to return a 404 error,
> which
> activeresource interprets as "throw a ResourceNotFound exception"
>
> If that is the case you would have to rescue/return nil wouldn't you?

I'm trying to use dynamic finder on the server side which returns
nil. Guess I have to switch to find with conditions instead.

Reply all
Reply to author
Forward
0 new messages