2009-07-02 16 views
4

würde Ich mag, wenn ein paar URL Neuversuche auf meiner alten Website überprüfen und URLS zu sammeln, die 404.Rubin URL öffnen und Rettungs

@paintings = Painting.find(:all) 
@paintings.each do |painting| 
    open("http://www.mydomain.com/" + painting.user.username.downcase + "/" + painting.permalink) 
    rescue OpenURI::HTTPError 
    @failure += painting.permalink 
    else 
    @success += painting.permalink 
    end 
    end 

Hmmm gibt kann ich nicht, dass Rettungsmethode die Fehler zu holen

syntax error, unexpected kRESCUE, expecting kEND 
     rescue OpenURI::HTTPError 

Irgendwelche Ideen?

Antwort

19

Sieht aus wie Sie die begin vor dem offenen vergessen haben:

begin 
    open("http://www.mydomain.com/" + painting.user.username.downcase + "/" + painting.permalink) 
rescue OpenURI::HTTPError 
    @failure += painting.permalink 
else 
    @success += painting.permalink 
end 
+0

Perfetct :) Danke. – atmorell