Skip to content
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

.ignore() does not apply to included resources #387

Open
ryabrody opened this issue Jul 13, 2020 · 0 comments
Open

.ignore() does not apply to included resources #387

ryabrody opened this issue Jul 13, 2020 · 0 comments

Comments

@ryabrody
Copy link
Contributor

In our app we are working with following user (localch-accounts) resource:

{
  "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze",
  "id": "p62qM5p0NK_qryO52Ze",
  ...
  "language": "de",
  "created_date": "2015-06-30T09:54:59.858+02:00",
  "claims": {
    "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze/claims",
    "items": [
      {
        "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze/claims/A00OhenWd_Z5RWnxDE7mqA",
        "localch_account": {
          "href": "http://api.test/localch-accounts/p62qM5p0NK_qryO52Ze"
        },
        "place": {
          "href": "http://api.test/places/A00OhenWd_Z5RWnxDE7mqA"
        },
   ...
}

When fetching the user (localch-accounts) we include the claims and also the place:

User.includes([claims: :place]).find('p62qM5p0NK_qryO52Ze')

Now it could be that a place does not exist anymore and we want to avoid running into a 404 by using .ignore(LHC::NotFound).

User.ignore(LHC::NotFound).includes([claims: :place]).find('p62qM5p0NK_qryO52Ze')

I now would expect that no 404 are raised.
But a 404 is raised because of a missing place.

With following references i can achieve the desired behavior but i would also expect this by just using ignore() as described above.

User.includes([claims: :place]).references(current_user_references).find('p62qM5p0NK_qryO52Ze')
...
def current_user_references
  [
    {
      claims: {
        place: {
          ignored_errors: [LHC::NotFound]
        }
      }
    }
  ]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant