Last active
December 16, 2015 12:09
-
-
Save radar/5432475 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def button_link(action_name, link_source) | |
klass = case action_name | |
when 'show' then { "icon-eye-open" => 'btn mini green-txt'} | |
when 'edit' then { "icon-pencil" => 'btn mini blue-txt' } | |
when 'delete' then { "icon-remove" => 'btn mini red-txt' } | |
end | |
content = "#{content_tag(:i, "", class: klass.keys)} #{content_tag :b, action_name.capitalize}".html_safe | |
if action_name == 'delete' | |
link_to(content, link_source, class: klass.values, | |
method: 'delete', | |
data: { confirm: "You sure?" }) | |
else | |
link_to(content, link_source, class: klass.values) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment