2013-02-23 118 views
0

成功实现从特雷弗土耳其人的博文"Easy Upload via URL with Paperclip"几次的代码已经经过无限递归,在这个最新的迭代我的应用程序给了我以下错误:用回形针远程图像上传

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 

而且我的脚/ _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。

+0

可以包含log/ .log(可能是enviorement = development)的错误吗?包括 – p1100i 2013-02-23 01:04:47

+0

@burninggramma。 – mattangriffel 2013-02-23 05:05:25

回答

1

在阅读'before_validation'的rails文档后,似乎如果你没有指定动作,即(before_validation:download_remote_image,on =>:create),那么它每次运行被调用的方法被改变。在这种情况下,调用before_validation方法,然后在该方法内,通过'self.image ='更改对象。如果你没有指定'on create',那么在这个阶段再次调用before_validation,从而重新启动download_remote_image方法。当它到达'self.image ='时,它会再次调用它,等等。所以也许在验证之前添加':on =>:create',或者在通过像'return if self.image.present?'之类的语句启动方法之前查看image对象是否已经存在。

我对轨道非常陌生,所以这个想法可能有缺陷,但它对我来说很有意义。

+0

我能够测试这一点,我的第一个想法是不去。必须在创建之前调用下载方法才能设置引脚的图像属性。唯一可以实现的方法是将return语句添加到方法的顶部。 – Clay 2013-03-04 02:24:55