質問編集履歴
1
コードを引用ではなく、コードブロックで記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,59 +32,69 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
> Rails.application.routes.draw do
|
36
|
-
|
37
|
-
> root "votes#index"
|
38
|
-
|
39
|
-
> resource :votes
|
40
|
-
|
41
|
-
> end
|
42
35
|
|
43
36
|
|
37
|
+
```
|
38
|
+
|
39
|
+
Rails.application.routes.draw do
|
40
|
+
|
41
|
+
root "votes#index"
|
42
|
+
|
43
|
+
resource :votes
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
```
|
44
48
|
|
45
49
|
*controller/concerns/votes_controller.rb
|
46
50
|
|
47
51
|
|
48
52
|
|
49
|
-
|
53
|
+
```
|
50
54
|
|
51
|
-
|
55
|
+
class VotesController < ApplicationController
|
52
56
|
|
53
|
-
> def index
|
54
57
|
|
55
|
-
> @vote = Vote.new
|
56
58
|
|
57
|
-
|
59
|
+
def index
|
58
60
|
|
59
|
-
|
61
|
+
@vote = Vote.new
|
60
62
|
|
61
|
-
|
63
|
+
end
|
62
64
|
|
63
|
-
> Vote.create(sex: params[:sex],age: params[:age])
|
64
65
|
|
65
|
-
> redirecte_to :root
|
66
66
|
|
67
|
-
|
67
|
+
def create
|
68
68
|
|
69
|
-
|
69
|
+
Vote.create(sex: params[:sex],age: params[:age])
|
70
70
|
|
71
|
-
|
71
|
+
redirecte_to :root
|
72
72
|
|
73
|
-
|
73
|
+
end
|
74
74
|
|
75
|
-
>
|
76
75
|
|
77
|
-
> private
|
78
76
|
|
79
|
-
|
77
|
+
def update
|
80
78
|
|
81
|
-
|
79
|
+
end
|
82
80
|
|
83
|
-
> end
|
84
81
|
|
85
|
-
>
|
86
82
|
|
83
|
+
private
|
84
|
+
|
85
|
+
def vote_params
|
86
|
+
|
87
|
+
params.require(:vote).permit(:sex,:age)
|
88
|
+
|
87
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
88
98
|
|
89
99
|
|
90
100
|
|
@@ -92,64 +102,68 @@
|
|
92
102
|
|
93
103
|
|
94
104
|
|
95
|
-
|
105
|
+
```
|
96
106
|
|
97
|
-
>
|
107
|
+
<%= form_for @vote do |f| %>
|
98
108
|
|
99
|
-
> <li>
|
100
109
|
|
101
|
-
> <%= f.label '男女をお選び下さい。'%></br>
|
102
110
|
|
103
|
-
|
111
|
+
<li>
|
104
112
|
|
105
|
-
|
113
|
+
<%= f.label '男女をお選び下さい。'%></br>
|
106
114
|
|
107
|
-
|
115
|
+
<%= f.radio_button 'sex','0'%><%= f.label '男'%>
|
108
116
|
|
109
|
-
>
|
117
|
+
<%= f.radio_button 'sex','1'%><%= f.label '女'%></br>
|
110
118
|
|
111
|
-
|
119
|
+
</li></br>
|
112
120
|
|
113
|
-
> <%= f.label '年齢層をお選び下さい。'%></br>
|
114
121
|
|
115
|
-
> <%= f.radio_button 'age','0'%><%= f.label '18~19歳'%>
|
116
122
|
|
117
|
-
|
123
|
+
<li>
|
118
124
|
|
119
|
-
|
125
|
+
<%= f.label '年齢層をお選び下さい。'%></br>
|
120
126
|
|
121
|
-
|
127
|
+
<%= f.radio_button 'age','0'%><%= f.label '18~19歳'%>
|
122
128
|
|
123
|
-
|
129
|
+
<%= f.radio_button 'age','1'%><%= f.label '20~24歳'%>
|
124
130
|
|
125
|
-
|
131
|
+
<%= f.radio_button 'age','2'%><%= f.label '25~29歳'%>
|
126
132
|
|
127
|
-
|
133
|
+
<%= f.radio_button 'age','3'%><%= f.label '30~34歳'%>
|
128
134
|
|
129
|
-
|
135
|
+
<%= f.radio_button 'age','4'%><%= f.label '35~39歳'%>
|
130
136
|
|
131
|
-
|
137
|
+
<%= f.radio_button 'age','5'%><%= f.label '40~44歳'%>
|
132
138
|
|
133
|
-
|
139
|
+
<%= f.radio_button 'age','6'%><%= f.label '45~49歳'%>
|
134
140
|
|
135
|
-
|
141
|
+
<%= f.radio_button 'age','7'%><%= f.label '50~54歳'%>
|
136
142
|
|
137
|
-
|
143
|
+
<%= f.radio_button 'age','8'%><%= f.label '55~59歳'%>
|
138
144
|
|
139
|
-
|
145
|
+
<%= f.radio_button 'age','9'%><%= f.label '60~64歳'%>
|
140
146
|
|
141
|
-
|
147
|
+
<%= f.radio_button 'age','10'%><%= f.label '65~69歳'%>
|
142
148
|
|
143
|
-
|
149
|
+
<%= f.radio_button 'age','11'%><%= f.label '70~74歳'%>
|
144
150
|
|
145
|
-
|
151
|
+
<%= f.radio_button 'age','12'%><%= f.label '75~79歳'%>
|
146
152
|
|
147
|
-
|
153
|
+
<%= f.radio_button 'age','13'%><%= f.label '80~84歳'%>
|
148
154
|
|
149
|
-
>
|
155
|
+
<%= f.radio_button 'age','14'%><%= f.label '85~89歳'%>
|
150
156
|
|
151
|
-
|
157
|
+
<%= f.radio_button 'age','15'%><%= f.label '90歳~'%></br>
|
152
158
|
|
153
|
-
>
|
159
|
+
</li></br>
|
154
160
|
|
161
|
+
|
162
|
+
|
163
|
+
<%= f.submit '完了' %>
|
164
|
+
|
165
|
+
|
166
|
+
|
155
|
-
|
167
|
+
<% end %>
|
168
|
+
|
169
|
+
```
|