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

find method on relationships #140

Open
barrerajl opened this issue May 31, 2023 · 3 comments
Open

find method on relationships #140

barrerajl opened this issue May 31, 2023 · 3 comments

Comments

@barrerajl
Copy link
Contributor

barrerajl commented May 31, 2023

So, I've found that cannot find do ... end on relationships. Which is not nice. Seems a little bit counterintuitive.
Would you be open to get a MR that detects if the method is receiving a block and use the collection instead of searching?
This was possible with Her gem and we also were using it before.
Something along these lines...

    # Overrides Enumerable find
    def find(id, &block)
      return scoping { klass.find(id) } if id
      super
    end

Really nice project here, thanks for all the good work!

@balvig
Copy link
Owner

balvig commented Jun 1, 2023

Thank you @barrerajl!
Is this the case just for relations or for f.ex User.find do ... end as well?
If you're happy to set up some tests/fix for this, that sounds good to me.

@barrerajl
Copy link
Contributor Author

Hey @balvig!
Would be only for relations. Is something that it is expected in Rails but find will not accept blocks.

@barrerajl
Copy link
Contributor Author

Here it is: #141

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

2 participants