I wonder if there’s a way to tighten this up:
def find_by_recordtype
e = EvLk.find_by_sql(<SQL QUERY>)
return (e.size > 0 ? e : nil)
end
I could do something like below but, prefer not to query twice.
return ( EvLk.find_by_sql().size > 0 ? EvLk.find_by_sql() : nil)
You're using
find_by_sql
so presumably you're in Rails or have ActiveSupport available. In that case, you can usepresence
:So you could do this: