rails/activeresource — pull request #68 by jassa (2013-04-26 00:01:46+00:00)
Title: Ensure belongs_to finder method sends a non-nil key

Hey there,
I found the following weird behavior:

Let's say a `Post` belongs_to a `User`, and there is a post without a `user_id`

post = Post.first # post without user_id
post.user.try(:name)
ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found .

On my logs I see it tried to get `users/.xml`

18:49:59 web.1 | Started GET "/api/users/.xml" for 127.0.0.1 at 2013-04-25 18:49:59 -0500
18:49:59 web.1 | ActionController::RoutingError (No route matches [GET] "/api/users/.xml"):

This PR fixes this, and returns `nil` instead:

post.user.try(:name)
=> nil

What do you think?

Additionally you might want to raise an ArgumentError when doing `Post.find nil` (same thing happens)