Directly access an object if it's present
Source: rubyquicktipsIf you want to access an object only if it’s present, you can use Rails’
Object#presence.
The API docs on presence have a good explanation:This is handy for any representation of objects where blank is the same as not present at all. For example, this simplifies a common check for HTTP…
-
oddlyzen liked this
-
davidfrancisco liked this
-
namxam reblogged this from rubyquicktips
-
namxam liked this
-
shielachan liked this
-
usman liked this
-
sanemat reblogged this from rubyquicktips
-
thisjourney liked this
-
ecleel liked this
-
yeswaynoway liked this
-
imnotquitejack liked this
-
rubyquicktips posted this