We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
どんな書き方しますか?
#もうvalidationがとおってるはずなので、validate: falseでsaveするパターン # ここで落ちたら超例外のはず。(DB死んでるとか) if objetct.valid? object.save validate: false end # validと同じタイミングでsaveするパターン if object.valid? && object.save end # 個人的に推奨したい # saveたたくとvalidが走るので、そもそも二つ書かない if object.save end #直撃でsave! if object.save! end # これもよいかも # valid?の後にエラーが出たら例外でおちてくれる。 if object.valid? object.save! end
どんなかんじでしょう?
The text was updated successfully, but these errors were encountered:
【まとめ】 validation以降に対象のobjectに修正を加えた場合、 save!を付けること。
修正を加えない場合は.saveにすること。
Sorry, something went wrong.
No branches or pull requests
どんな書き方しますか?
どんなかんじでしょう?
The text was updated successfully, but these errors were encountered: