Skip to content

Instantly share code, notes, and snippets.

@taea
Last active December 16, 2015 06:49
Show Gist options
  • Select an option

  • Save taea/5394293 to your computer and use it in GitHub Desktop.

Select an option

Save taea/5394293 to your computer and use it in GitHub Desktop.
Haml: 値が存在する場合だけ表示 をワンライナーで → try
= "#{@person.try(:name)}"
-# もしくは
= "#{"#{@person.name}" if @person.name.present?}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment