<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Yamakichi</author_name>
  <author_url>https://blog.hatena.ne.jp/Yamakichi/</author_url>
  <blog_title>blog</blog_title>
  <blog_url>https://yamakichi.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
    <anon>Rails</anon>
    <anon>Tips</anon>
  </categories>
  <description>Rails ActiveRecordで複数のカラムに対して一意制約を設ける。複合一意制約複数のカラムの組み合わせがユニークであってほしい場面に遭遇しました。例えば、Siteテーブル Keywordテーブルが存在する時、Keywordテーブルにある site_id と name そして date の組み合わせはユニークでなければいけない状況でした。 site_id, name, date の組み合わせがユニーク この組み合わせのユニークを担保するために、Railsアプリケーション側でユニークであることを確認するvalidate処理を設けて解決させました。 class Keyword &lt; Acti…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyamakichi.hatenablog.com%2Fentry%2F2016%2F08%2F25%2F003738&quot; title=&quot;Rails 複数のカラムに 一意制約 (ユニーク)を設ける - blog&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>2016-08-25 00:37:38</published>
  <title>Rails 複数のカラムに 一意制約 (ユニーク)を設ける</title>
  <type>rich</type>
  <url>https://yamakichi.hatenablog.com/entry/2016/08/25/003738</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
