-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introspecting a model with a custom path throws an exception #87
Comments
Does you |
No it doesn't, it is just basic information, e.g.: {
"id": 54,
"name": "Luca"
} In my actual use case (as opposed to this example), the child can belong to multiple parents, so it doesn't make sense to have a single |
Ah I see. Her is indeed calling the request path for each In your actual use case, what URL would be called if you call the class User
collection_path "/companies/:company_id/users"
resource_path "/users/:id"
end |
Sorry for the delay, we've been busy busy recently... Back to the issue, so the actual model in our case is read-only, so we don't need to worry about saving it. However if we did the the example you provided would be correct. I think for now we'll just add some custom stuff to stop the |
I think we could just catch any exceptions when calling class User
collection_path "/companies/:company_id/users"
end
user1 = User.find(1) # { "id": 1, "name": "Tobias Fünke", "company_id": 2 }
user1.inspect # => #<User(/companies/2/users/1) name="Tobias Fünke">
user2 = User.find(2) # { "id": 2, "name": "Maeby Fünke" }
user2.inspect # => #<User(<unknown path>) name="Maeby Fünke"> That makes sense, right? |
That sounds good to me :) |
This commit should fix it. If I take my previous example again: class User
collection_path "/companies/:company_id/users"
end
user1 = User.find(1) # { "id": 1, "name": "Tobias Fünke", "company_id": 2 }
user1.inspect # => #<User(/companies/2/users/1) name="Tobias Fünke">
user2 = User.find(2) # { "id": 2, "name": "Maeby Fünke" }
user2.inspect # => #<User(<unknown path, missing `company_id`>) name="Maeby Fünke"> |
Great! It's been annoying for a long time ;) @lucaspiller Can you verify and close the issue? |
@lucaspiller You should not be experiencing the issue with newer versions of |
Works perfect, thanks! |
Given the following model:
If in the console I do the following it works:
However the following throws an error:
This is because
#inspect
calls#request_path
again, but without the parameters.The text was updated successfully, but these errors were encountered: