質問編集履歴
2
ファイル名追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,7 +14,8 @@
|
|
14
14
|
|
15
15
|
### 該当のソースコード
|
16
16
|
|
17
|
+
```
|
17
|
-
|
18
|
+
article.rb
|
18
19
|
|
19
20
|
def self.search(search_word)
|
20
21
|
if search_word
|
@@ -25,11 +26,13 @@
|
|
25
26
|
end
|
26
27
|
```
|
27
28
|
|
29
|
+
```
|
28
|
-
|
30
|
+
tops_controller.rb
|
29
31
|
@articles = Article.search(params[:search])
|
30
32
|
```
|
31
33
|
|
32
34
|
```
|
35
|
+
index.html.erb
|
33
36
|
<% @articles.each do |article| %>
|
34
37
|
<div class = "article-box">
|
35
38
|
<div class = "image">
|
1
ビューファイル追加しました!
title
CHANGED
File without changes
|
body
CHANGED
@@ -29,6 +29,22 @@
|
|
29
29
|
@articles = Article.search(params[:search])
|
30
30
|
```
|
31
31
|
|
32
|
+
```
|
33
|
+
<% @articles.each do |article| %>
|
34
|
+
<div class = "article-box">
|
35
|
+
<div class = "image">
|
36
|
+
<%= link_to image_tag("#{article.image_url}",:class=>"image"), top_path(:id => article.id) %>
|
37
|
+
</div>
|
38
|
+
<h3 class="title"><%= link_to article.title , top_path(:id => article.id)%></h3>
|
39
|
+
<p class = "tag"><%= link_to article.tags.first.name, "#" %></p>
|
40
|
+
<time class="date"><%= article.created_at.strftime("%Y-%m-%d") %></time>
|
41
|
+
</div>
|
42
|
+
<% end %>
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
32
48
|
### 試したこと
|
33
49
|
|
34
50
|
joinについてやincludeについなども調べたんですがどうやって書くと上手くいくのか解決策が見つかりませんでした、、
|