If you create an assistant like this:
module BootstrapIconHelper
def icon_link_to(path, opts = {}, link_opts = {})
classes = []
[:icon, :blank].each do |klass|
if k = opts.delete(klass)
classes << "#{klass}-#{k}"
end
end
classes << "enlarge" if opts.delete(:enlarge)
opts[:class] ||= ""
opts[:class] << " " << classes.join(" ")
link_to content_tag(:i, "", opts), path, link_opts
end
end
You can write your links as follows:
<%= icon_link_to(
vote_against_mission_mission_path(:id => mission.id),
{ :icon => "chevron-down", :blank => "vote", :enlarge => true },
{:method => :post}
) %>
<%= icon_link_to(
collect_mission_path(controller: "folders", action: "collect", id: mission.id),
{ :icon => "heart", :blank => "favorite", :enlarge => true, id: "action-centering}
) %>
source
share