17
I use a utility method.
def until_not_blank(*args)
args.find {|a| !a.blank? }
end
url = until_not_blank(file.s3_url, file.url)
I typically just put that in my ApplicationController and make it a helper. If you wanted it to be available globally, you could put it in Kernel, or you could monkey-patch Array
class Array
def first_not_blank
find {|a| !a.blank?}
end
end
url = [file.s3_url, file.url].first_not_blank