Grab id for exception message from request object#7
Grab id for exception message from request object#7mecampbellsoup wants to merge 1 commit intotiagopog:masterfrom
Conversation
|
|
||
| def jsonapi_render_not_found(exception) | ||
| setup_request | ||
| id = exception.message.match(/=(\d+)/)[1] |
There was a problem hiding this comment.
@tiagopog this regex was failing in our test suite because we are using UUIDs as primary keys, which aren't strings of strictly digits.
|
Sure, I actually started working on that. Up to the weekend I guess we're done. |
|
👍 |
|
Well, in this case we would need to test when there is more than one identifier being passed in the request. I'm not sure right now if we could easily know which one was not found using only the request object. Through the exception message it's quite easy to "access" this information. But I'm totally open for suggestions, especially now considering the case of uuid's. |
|
Hey, just let me know when you finish testing the suggested code against a request with multiple identifiers e.g. |
|
I have some work to get done now, so I may also test it later :-) |
|
Will do man, not going to be today, hopefully tomorrow or later this week :) On April 13, 2016 at 11:38:02 AM, Tiago Guedes (notifications@github.com) wrote: I have some work to get done now, so I may also test it later :-) — |
No need for the regex as the desired
idattribute is available as an instance variable on the request object.