Created
March 28, 2013 11:00
-
-
Save dux/5262359 to your computer and use it in GitHub Desktop.
safe rails for replacement. on runtime error, reports error and object, does not brake the application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sfor(list, &block) | |
for el in list | |
begin | |
yield(el) | |
rescue | |
concat(%[<div style="background-color:#fdd; padding:4px; border:1px solid #ccc;"><ul><li>Object: #{}#{el.as_link rescue '-'} (#{el.class.name})</li><li>Error: #{$!}</li></ul></div>]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment