<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>sonata30</author_name>
  <author_url>https://blog.hatena.ne.jp/sonata30/</author_url>
  <blog_title>my_back_pages</blog_title>
  <blog_url>https://shodan.hatenablog.jp/</blog_url>
  <categories>
    <anon>Rails</anon>
  </categories>
  <description>まとめ UserモデルとAuthorモデルがある 既存のユーザー（user）にアタッチしてあるファイルを、そのまま流用して別の「著者」（author）にアタッチしたい 上記のことが、以下のコードで可能という記事です。 author.authors_image.attach(user.users_image.blob) やってみる rails newして、User / Author モデルを作る ActiveStorageを導入して、has_one_attachedでモデルとファイルを紐づける設定をする ビューで画像を表示できるようにしておく 下のサンプルコードはUserのビューのものだけだが、…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fshodan.hatenablog.jp%2Fentry%2F2025%2F02%2F23%2F124925&quot; title=&quot;【Rails】ActiveStorageで、既存のオブジェクトに紐づいたファイルを他のオブジェクトに流用して紐づける方法 - my_back_pages&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>https://cdn-ak.f.st-hatena.com/images/fotolife/s/sonata30/20250223/20250223114749.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-02-23 12:49:25</published>
  <title>【Rails】ActiveStorageで、既存のオブジェクトに紐づいたファイルを他のオブジェクトに流用して紐づける方法</title>
  <type>rich</type>
  <url>https://shodan.hatenablog.jp/entry/2025/02/23/124925</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
