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

Allow optional block for #find_or_create_by #165

Merged

Conversation

fugakkbn
Copy link
Contributor

@fugakkbn fugakkbn commented Jun 5, 2022

ActiveRecord::Relation#find_or_create_by(!) type definition requires a block.
If we try to run without blocks, we will get the following error:

[error] The method cannot be called without a block
│ Diagnostic ID: Ruby::RequiredBlockMissing
│
└     users.find_or_create_by!(nickname: fugakkbn)

However, since there are cases where it is called without a block, this PR makes the change to make the block optional.

Copy link
Member

@pocke pocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pocke pocke merged commit 21f137a into ruby:main Jun 7, 2022
@fugakkbn fugakkbn deleted the allow_optional_block_for_find_or_create_by branch October 13, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants