質問編集履歴
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
|
17
|
+
### index.html.slim
|
18
18
|
|
19
19
|
```
|
20
20
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
```
|
54
54
|
|
55
|
-
|
55
|
+
### _search_form.html.slim
|
56
56
|
|
57
57
|
```
|
58
58
|
|
@@ -66,4 +66,60 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
+
### students_controller
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
class StudentsController < ApplicationController
|
74
|
+
|
75
|
+
def index
|
76
|
+
|
77
|
+
@q = Student.ransack(params[:q])
|
78
|
+
|
79
|
+
@students = @q.result(distinct: true)
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
def search
|
86
|
+
|
87
|
+
@q = Student.search(search_params)
|
88
|
+
|
89
|
+
@students = @q.result(distinct: true)
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def search_params
|
98
|
+
|
99
|
+
params.require(:q).permit!
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
### routes.rb
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
Rails.application.routes.draw do
|
114
|
+
|
115
|
+
root to: 'students#index'
|
116
|
+
|
117
|
+
get 'search', to: 'students#search'
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
69
125
|
まだ初学者の域を出ないため、とんちんかんなことを言ってるかもしれませんが、どなたか原因が分かる方に教えていただけるとありがたいです。
|