回答編集履歴
1
コード修正
answer
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
`
|
1
|
+
自分ならこんな感じですかね。余談ですが `image_for` はかなり汎用的な名前なのであまりいいヘルパメソッド名ではないように思います。
|
2
2
|
|
3
3
|
```ruby
|
4
4
|
module UsersHelper
|
5
|
-
|
5
|
+
def user_profile_img(user)
|
6
|
-
if user.try(:image)
|
7
|
-
|
6
|
+
path = user.try(:image) ? "/user_images/#{user.image}" : "kikirara.png"
|
8
|
-
else
|
9
|
-
|
7
|
+
image_tag path, class: "profile_img"
|
10
|
-
end
|
11
8
|
end
|
12
9
|
end
|
13
10
|
```
|