<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>a2ikm</author_name>
  <author_url>https://blog.hatena.ne.jp/a2ikm/</author_url>
  <blog_title>There's an echo in my head</blog_title>
  <blog_url>https://ikm.hatenablog.jp/</blog_url>
  <categories>
    <anon>ruby</anon>
    <anon>gem</anon>
    <anon>activerecord</anon>
  </categories>
  <description>schema_plusを使うとcreate_tableやadd_columnでカラムを定義するときに:referencesオプションにテーブル名を渡すだけで、外部キー制約を手軽にかけることができる。 create_table :posts do |t| t.integer :category_id, references: :categories end 個々に指定するのが面倒なときは、auto_createを設定すれば名前が*_idにマッチするカラムに対して自動的に外部キー制約をかけてくれる。 SchemaPlus.config.foreign_keys.auto_create = true…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fikm.hatenablog.jp%2Fentry%2F2012%2F11%2F02%2F023508&quot; title=&quot;schema_plusで外部キー制約をかける - There&amp;#39;s an echo in my head&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>2012-11-02 02:35:08</published>
  <title>schema_plusで外部キー制約をかける</title>
  <type>rich</type>
  <url>https://ikm.hatenablog.jp/entry/2012/11/02/023508</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
