ActiveRecordのオブジェクトに、 簡単に画像を添付して登録できるPaperclipというプラグインがあります。 一般的な使い方は、ブラウザのフォームから、画像を送信して画像を登録するのですが、 rails runnerで動かすスクリプト等でも使いたいので、 ローカルのディスクに保存してあるファイルからの登録をしてみます。 事前に、下記のwikiを参考に、paperclipのインストール、ActiveRecordへのコードの追加を済ませておいてください。 paperclip wiki 下記の例では、Machineオブジェクトに、imageという名前でpaperclipを設定しています。 class Machine { :medium => "300x300>", :thumb => "100x100>" } end まずは、登録したい画像オブジェクトを、抽出します。