Skip to content

Instantly share code, notes, and snippets.

@takuyan
Created September 25, 2013 05:16
Show Gist options
  • Save takuyan/6695408 to your computer and use it in GitHub Desktop.
Save takuyan/6695408 to your computer and use it in GitHub Desktop.
FontAwesomeを使うときは、ApplicationHelperにコレを登録しておくと便利。 どんどんwhen句を増やせば良い。データごとのアイコンを一元管理。 メリット:アイコン名をハードコーディングしなくて済む
module ApplicationHelper
def icon_name_for(name)
sym_name = name.to_sym
case sym_name
when :home
'icon-dashboard'
when :team
'icon-group'
when :content
'icon-pencil'
else
"icon-#{name}"
end
end
def icon_for(name)
content_tag :i, '', class: icon_name_for(name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment