Skip to content

Instantly share code, notes, and snippets.

@efatsi
Created September 13, 2012 00:22
Show Gist options
  • Save efatsi/3710954 to your computer and use it in GitHub Desktop.
Save efatsi/3710954 to your computer and use it in GitHub Desktop.
if !current_user.nil?
@applicant ||= current_user.applicant
@applicant ||= Applicant.new if @applicant.nil?
end
# Refactor to
if current_user.present?
@applicant ||= current_user.applicant || Applicant.new
end
# and depending on implementation
@applicant ||= current_user.try(:applicant) || Applicant.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment