diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index 8723af7..809afad 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -196,7 +196,7 @@ class OlympiamanagementsController < ApplicationController render_contents_in_index_page(@breadcumb+"
#{I18n.t('olympiamanagement.please_set_school_connect_data')}
".html_safe) else @student_data_field = StudentDataField.first - @olympia_student_data = OlympiaStudentDataFields.new + @olympia_student_data = (OlympiaStudentDataFields.find(params[:id]) rescue OlympiaStudentDataFields.new) @page_content = render_to_string(:formats=> [:html] ,:partial=>'add_student_data.html',:locals=>{:@error=>(@@error rescue nil),:@student_data_field=>@student_data_field,:@olympia_student_data=>@olympia_student_data}) render_contents_in_index_page(@breadcumb+@page_content.html_safe) end @@ -529,8 +529,9 @@ class OlympiamanagementsController < ApplicationController end def updata_student_data if params[:type] == 'add_student_data' - @olympia_student_data = OlympiaStudentDataFields.create(params.require(:add_student_data).permit(:StudentIdentity,:StudentName,:StudentSex,:StudentIDNO, - :StudentBirthMonth,:StudentBirthDay,:StudentClass,:StudentPhone,:StudentCode,:StudentAddress,:StudentArea,:StudentFile)) + @student_params = params.require(:add_student_data).permit(:StudentIdentity,:StudentName,:StudentSex,:StudentIDNO,:StudentBirthMonth,:StudentBirthDay,:StudentClass,:StudentPhone,:StudentCode,:StudentAddress,:StudentArea,:StudentFile) + @olympia_student_data = OlympiaStudentDataFields.find(params[:id]) rescue nil + @olympia_student_data.nil? ? OlympiaStudentDataFields.create(@student_params) : @olympia_student_data.update_attributes(@student_params) redirect_to sign_up_student_data_list_olympiamanagements_path else render :html => '404' diff --git a/app/views/olympiamanagements/_add_student_data.html.erb b/app/views/olympiamanagements/_add_student_data.html.erb index 0a9f3d6..a1bd406 100644 --- a/app/views/olympiamanagements/_add_student_data.html.erb +++ b/app/views/olympiamanagements/_add_student_data.html.erb @@ -15,7 +15,7 @@ <%end%>