0

TrevorTurkのブログ投稿「Paperclipを使用したURL経由のEasyUpload のコードをすでに数回正常に実装した後、この最新の反復で、私のアプリは次のエラーを表示します。

Started POST "/pins" for 127.0.0.1 at 2013-02-22 14:05:20 -0300
Processing by PinsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Q6kmHS7Co+j2Y4JYd+3YO0OmDHU/upK1ADvRbS8UAIc=", "pin"=>{"image_url"=>"http://media-cache-ec3.pinterest.com/550x/b4/b7/82/b4b782bf268cb52d201853886510e3a9.jpg", "description"=>"Test"}, "commit"=>"Create Pin"}
  [1m[36mUser Load (0.2ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1[0m
  [1m[35m (0.1ms)[0m  begin transaction
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-c7vstl'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-17pzds5'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1kh7v9y'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-ngtq1u'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-jzmkac'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1x4vpj5'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1iwdp4q'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-cvro9z'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1tn727x'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-q77ipe'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1e5wt1x'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-7xaoic'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-kzw7ab'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-m1frw1'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-aojdb8'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-kzn0w6'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-cj55fi'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-d3s1h0'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-15hmo2q'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-17apjuj'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-f97eej'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1t9ou1f'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1dfnz21'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-ozc0ac'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1uiz51r'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-57ahli'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-u96rmb'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-vt2ph3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-st55ih'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1phbyb3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-wdu3nu'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1iit16u'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-117n6l2'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-qr5380'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-tod0l9'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1u19f33'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1rta45x'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-6o0hug'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-14e2zh7'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1lnwdhm'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-9en3jt'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-hhb0b2'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-9b0ak8'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1yyvnl9'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-15ebo0r'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-kpavxm'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-qgrtq2'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1erqxe5'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1h23wb0'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1heb0b3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1oswpj8'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1y1z7di'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-89spzg'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-96op3f'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-4aizhy'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1s5nw68'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-k4jb2y'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1gjqddi'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1nzej79'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1yurmzq'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1yvoyxn'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-ec4b0b'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-12zau9q'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-va8ryp'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-11362zg'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-14d0lek'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-65t94r'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-2zqkrs'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-nzvtnc'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-mokk7l'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1v6n3k3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-7tvcwq'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-z4qieu'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-5let78'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1azr7s1'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-xfbbhj'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-qpuxih'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1oqv313'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1lw2iyw'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-sgsyl7'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-z3kc9d'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1csf869'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1615j19'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-gjlms9'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1t0vhjc'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1x2w35'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1wgmxox'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-ce9qo7'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1mxr8v0'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1y1716x'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-19vj2ky'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1s2yq7p'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-10xd3y3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-fohqek'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1p8i5y4'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-mx211u'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-nhtv6r'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1sdvwt9'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1nu8xde'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1yo03yt'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-pfu1cg'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-oqslme'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1s8wcup'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1x91fzc'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1b3zxzf'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1miary7'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-18ef2u'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-eo8odm'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1noqove'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-hl4yhz'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-mqjd16'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-10do8b2'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-n1dqn2'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1raiaq5'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1myor64'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1i2e0b3'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-hgtnym'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-lzuyqt'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-1cvazmm'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-shgn3h'
Command :: file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-a1n19w'
  [1m[36m (0.1ms)[0m  [1mrollback transaction[0m
Completed 500 Internal Server Error in 201007ms

Errno::EMFILE (Too many open files - file -b --mime '/var/folders/8z/sh44jtbs33163s5hsjxj6tsc0000gr/T/open-uri20130222-25293-a1n19w'):
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/models/pin.rb:27:in `download_remote_image'
  app/controllers/pins_controller.rb:48:in `block in create'
  app/controllers/pins_controller.rb:47:in `create'

どこかはわかりませんが、ある種の無限再帰が発生しているようです。

関連するモデルは次のようになります。

require 'open-uri'

class Pin < ActiveRecord::Base
  belongs_to :user
  attr_accessible :description, :image, :image_url

  has_attached_file :image, styles: { medium: "320x240>"}

  validates :description, presence: true
  validates :user_id, presence: true
  validates_attachment :image, presence: true,
                                                         content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'] },
                                                         size: { less_than: 5.megabytes }


  # Remote image downloading
  attr_accessor :image_url
  before_validation :download_remote_image, :if => :image_url_provided?

  private

    def image_url_provided?
      !self.image_url.blank?
    end

    def download_remote_image
      self.image = URI.parse(image_url)
      # self.image_remote_url = image_url
    end

    def do_download_remote_image
      io = open(URI.parse(image_url))
      def io.original_filename; base_uri.path.split('/').last; end
      io.original_filename.blank? ? nil : io
    rescue # catch url errors with validations instead of exceptions (Errno::ENOENT, OpenURI::HTTPError, etc...)
      print "An error occurred: ",$!, "\n"
    end
end

そして私のpins/_form.html.erb

<%= simple_form_for(@pin, html: { class: "form-horizontal"}) do |f| %>
  <%= f.error_notification %>
  <%= f.full_error :image_file_size, class: "alert alert-error" %>
  <%= f.full_error :image_content_type, class: "alert alert-error" %>

  <%= f.input :image, label: "Upload an image" %>
  <%= f.input :image_url, label: false, placeholder: "http://" %>
  <%= f.input :description, as: :text, input_html: { rows: "3" } %>

  <div class="form-actions">
    <%= f.button :submit, class: "btn btn-primary" %>
  </div>
<% end %>

最後に、私のピンコントローラーはかなり標準的です:

  def new
    @pin = current_user.pins.build

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @pin }
    end
  end

  def create
    @pin = current_user.pins.build(params[:pin])

    respond_to do |format|
      if @pin.save
        format.html { redirect_to @pin, notice: 'Pin was successfully created.' }
        format.json { render json: @pin, status: :created, location: @pin }
      else
        format.html { render action: "new" }
        format.json { render json: @pin.errors, status: :unprocessable_entity }
      end
    end
  end

download_remote_imageを何度も実行しているようです。

4

1 に答える 1

1

「before_validation」に関するレールのドキュメントを読んだ後、アクションを指定しない場合、つまり (before_validation :download_remote_image, :on => :create)、オブジェクトが変更されるたびに呼び出されたメソッドが実行されるようです。この場合、before_validation メソッドが呼び出され、メソッド内で「self.image =」を介してオブジェクトが変更されます。「作成時」を指定しない場合、この段階で before_validation が再度呼び出されるため、download_remote_image メソッドが再開されます。「self.image=」に到達すると、再度呼び出します。したがって、検証前に「:on => :create」を追加するか、「return if self.image.present?」などのステートメントを使用してメソッドを開始する前に、画像オブジェクトが既に存在するかどうかを確認してください。

私はレールにかなり慣れていないので、この考えには欠陥があるかもしれませんが、私には理にかなっています。

于 2013-03-03T23:38:49.490 に答える