質問編集履歴
1
質問修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
application_helper / content_tagメソッドを使ったスペースの表示
|
body
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
`erb`の以下記載が何となく見通し悪くしているので、`application_helper`に制御を切り出し
|
1
|
+
`erb`の以下記載が何となく見通し悪くしているので、`application_helper`に制御を切り出しています。
|
2
|
+
`erb`内に記載ある` (半角スペース)`を`helper`内の`content_tag`メソッドで使用するにはどうすれば良いのでしょうか?
|
2
3
|
|
3
4
|
```html
|
5
|
+
#erbを使用
|
4
6
|
<% @adviser.lessons.each do |lesson| %>
|
5
7
|
<% if lesson.votes.count.blank? %>
|
6
8
|
<span class="top-like">
|
@@ -13,15 +15,15 @@
|
|
13
15
|
<% end %>
|
14
16
|
```
|
15
17
|
|
16
|
-
色々tryしましたが、うまくいきません。
|
17
18
|
```ruby
|
18
19
|
#application_helper.rb
|
19
20
|
|
20
21
|
def vote_count(lesson)
|
21
|
-
|
22
|
+
if lesson.votes.blank?
|
23
|
+
content_tag(:span, content_tag(:i, "", class: "fa fa-heart-o", "aria-hidden" => "true"), class: "top-like")
|
24
|
+
else
|
22
|
-
|
25
|
+
count = lesson.votes.count
|
26
|
+
content_tag(:span, content_tag(:i, count, class: "fa fa-heart"), class: "top-like")
|
23
|
-
|
27
|
+
end
|
24
28
|
end
|
25
|
-
end
|
26
|
-
|
27
29
|
```
|