<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kamipo</author_name>
  <author_url>https://blog.hatena.ne.jp/kamipo/</author_url>
  <blog_title>かみぽわーる</blog_title>
  <blog_url>https://blog.kamipo.net/</blog_url>
  <categories>
  </categories>
  <description>Active Recordの話です。 create_or_find_byの実装はcreateしてみてユニーク制約に引っかかったらfind_byしてみるなので、ふつうに考えるとfind_byは成功しそうに見えます。 def create_or_find_by(attributes, &amp;block) transaction(requires_new: true) { create(attributes, &amp;block) } rescue ActiveRecord::RecordNotUnique find_by!(attributes) end ですが、以下のスクリプトを実行するとcreate_o…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.kamipo.net%2Fentry%2F2020%2F12%2F16%2F190723&quot; title=&quot;create_or_find_byでcreateもfind_byも失敗させる - かみぽわーる&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-12-16 19:07:23</published>
  <title>create_or_find_byでcreateもfind_byも失敗させる</title>
  <type>rich</type>
  <url>https://blog.kamipo.net/entry/2020/12/16/190723</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
