Use content_tag.

Akinori MUSHA 10 years ago
parent
commit
a224a0b908
1 changed files with 5 additions and 13 deletions
  1. 5 13
      app/helpers/application_helper.rb

+ 5 - 13
app/helpers/application_helper.rb

@@ -1,27 +1,19 @@
1 1
 module ApplicationHelper
2 2
   def nav_link(name, path, options = {})
3
-    (<<-HTML).html_safe
4
-      <li class='#{(current_page?(path) ? "active" : "")}'>
5
-        #{link_to name, path}
6
-      </li>
7
-    HTML
3
+    content_tag :li, link_to(name, path), class: current_page?(path) ? 'active' : ''
8 4
   end
9 5
 
10 6
   def yes_no(bool)
11
-    if bool
12
-      '<span class="label label-info">Yes</span>'.html_safe
13
-    else
14
-      '<span class="label label-default">No</span>'.html_safe
15
-    end
7
+    content_tag :span, bool ? 'Yes' : 'No', class: "label #{bool ? 'label-info' : 'label-default' }"
16 8
   end
17 9
 
18 10
   def working(agent)
19 11
     if agent.disabled?
20
-      link_to 'Disabled', agent_path(agent), :class => 'label label-warning'
12
+      link_to 'Disabled', agent_path(agent), class: 'label label-warning'
21 13
     elsif agent.working?
22
-      '<span class="label label-success">Yes</span>'.html_safe
14
+      content_tag :span, 'Yes', class: 'label label-success'
23 15
     else
24
-      link_to 'No', agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details')), :class => 'label label-danger'
16
+      link_to 'No', agent_path(agent, tab: (agent.recent_error_logs? ? 'logs' : 'details')), class: 'label label-danger'
25 17
     end
26 18
   end
27 19
 end