Description:
fixed problem insertion attribute error
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r775:3d1a060b0378 - - 1 file changed: 5 inserted, 1 deleted
@@ -20,25 +20,25 | |||||
|
20 |
|
20 | ||
|
21 | def show |
|
21 | def show |
|
22 | @problem = Problem.find(params[:id]) |
|
22 | @problem = Problem.find(params[:id]) |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | def new |
|
25 | def new |
|
26 | @problem = Problem.new |
|
26 | @problem = Problem.new |
|
27 | @description = nil |
|
27 | @description = nil |
|
28 | end |
|
28 | end |
|
29 |
|
29 | ||
|
30 | def create |
|
30 | def create |
|
31 | @problem = Problem.new(problem_params) |
|
31 | @problem = Problem.new(problem_params) |
|
32 |
- @description = Description.new( |
|
32 | + @description = Description.new(description_params) |
|
33 | if @description.body!='' |
|
33 | if @description.body!='' |
|
34 | if !@description.save |
|
34 | if !@description.save |
|
35 | render :action => new and return |
|
35 | render :action => new and return |
|
36 | end |
|
36 | end |
|
37 | else |
|
37 | else |
|
38 | @description = nil |
|
38 | @description = nil |
|
39 | end |
|
39 | end |
|
40 | @problem.description = @description |
|
40 | @problem.description = @description |
|
41 | if @problem.save |
|
41 | if @problem.save |
|
42 | flash[:notice] = 'Problem was successfully created.' |
|
42 | flash[:notice] = 'Problem was successfully created.' |
|
43 | redirect_to action: :index |
|
43 | redirect_to action: :index |
|
44 | else |
|
44 | else |
@@ -243,24 +243,28 | |||||
|
243 | def remove_contest |
|
243 | def remove_contest |
|
244 | problem = Problem.find(params[:id]) |
|
244 | problem = Problem.find(params[:id]) |
|
245 | contest = Contest.find(params[:contest_id]) |
|
245 | contest = Contest.find(params[:contest_id]) |
|
246 | if problem!=nil and contest!=nil |
|
246 | if problem!=nil and contest!=nil |
|
247 | problem.contests.delete(contest) |
|
247 | problem.contests.delete(contest) |
|
248 | end |
|
248 | end |
|
249 | redirect_to :action => 'manage' |
|
249 | redirect_to :action => 'manage' |
|
250 | end |
|
250 | end |
|
251 |
|
251 | ||
|
252 | ################################## |
|
252 | ################################## |
|
253 | protected |
|
253 | protected |
|
254 |
|
254 | ||
|
|
255 | + def description_params | ||
|
|
256 | + params.require(:description).permit(:body, :markdowned) | ||
|
|
257 | + end | ||
|
|
258 | + | ||
|
255 | def allow_test_pair_import? |
|
259 | def allow_test_pair_import? |
|
256 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
260 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
257 | return ALLOW_TEST_PAIR_IMPORT |
|
261 | return ALLOW_TEST_PAIR_IMPORT |
|
258 | else |
|
262 | else |
|
259 | return false |
|
263 | return false |
|
260 | end |
|
264 | end |
|
261 | end |
|
265 | end |
|
262 |
|
266 | ||
|
263 | def change_date_added |
|
267 | def change_date_added |
|
264 | problems = get_problems_from_params |
|
268 | problems = get_problems_from_params |
|
265 | date = Date.parse(params[:date_added]) |
|
269 | date = Date.parse(params[:date_added]) |
|
266 | problems.each do |p| |
|
270 | problems.each do |p| |
You need to be logged in to leave comments.
Login now