Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 411 Bytes

2019-08-21_rails_presence.md

File metadata and controls

17 lines (10 loc) · 411 Bytes

Presence Method (Rails)

8/21/2019

Presence is a Rails method that check for the presence of an item, and returns nil if it is not there:

user = params[:user] if params[:user].present?

## The above code can be written as

user = params[:user].presence

Ruby on Rails API Doc

h/t to marybethlee