質問編集履歴
1
recruitments_controller.rbのコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -91,3 +91,129 @@
|
|
91
91
|
end
|
92
92
|
|
93
93
|
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
recruitments_controller.rb
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
class RecruitmentsController < ApplicationController
|
110
|
+
|
111
|
+
def index
|
112
|
+
|
113
|
+
@recruitments = Recruitment.all.page(params[:page]).per(5).order("updated_at DESC")
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
def new
|
120
|
+
|
121
|
+
@recruitments = Recruitment.new
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
def create
|
128
|
+
|
129
|
+
@recruitments = Recruitment.new(recruitment_params)
|
130
|
+
|
131
|
+
if @recruitments.save
|
132
|
+
|
133
|
+
redirect_to users_path
|
134
|
+
|
135
|
+
else
|
136
|
+
|
137
|
+
render "new"
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
def show
|
146
|
+
|
147
|
+
@recruitment = Recruitment.find(params[:id])
|
148
|
+
|
149
|
+
@user = @recruitment.user
|
150
|
+
|
151
|
+
@fovorites = @recruitment.favorites
|
152
|
+
|
153
|
+
@favorite = Favorite.new
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
def destroy
|
160
|
+
|
161
|
+
recruitment = Recruitment.find(params[:id])
|
162
|
+
|
163
|
+
recruitment.destroy
|
164
|
+
|
165
|
+
redirect_to "/users/#{current_user.id}"
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
def edit
|
172
|
+
|
173
|
+
@recruitment = Recruitment.find(params[:id])
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
def update
|
180
|
+
|
181
|
+
recruitment = Recruitment.find(params[:id])
|
182
|
+
|
183
|
+
recruitment.update(recruitment_edit_params)
|
184
|
+
|
185
|
+
redirect_to :action => 'show'
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def recruitment_params
|
202
|
+
|
203
|
+
params.permit(:recruitment_title, :recruitment_type, :study_period, :recruitment_overview, :production_period, :production).merge(user_id: current_user.id)
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
def recruitment_edit_params
|
210
|
+
|
211
|
+
params.require(:recruitment).permit(:recruitment_title, :recruitment_type, :study_period, :recruitment_overview, :production_period, :production).merge(user_id: current_user.id)
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
```
|