Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def graph_instructions_update
- attr = params[:user][:user_instruction_refs_attributes]['0']
- head = Department.find_by_id(resource.department_id) if resource.department_id
- program = Course.find_by_id(attr[:instruction_id]) if attr[:instruction_id].present?
- @session = @user.sessions_upcoming.find_or_create_by(
- user_id: @user.id ,
- head_user_id: head.head_id,
- instruction_id: (attr[:instruction_id] if attr[:instruction_id].present?),
- allowed_period_start: (attr[:date] if attr[:date].present?),
- program_code: (program.code if program),
- program_title: (program.title if program),
- program_item_id: 2571,
- user_instruction_last: 1)
- params[:user][:user_instruction_refs_attributes]['0'][:session_id] = @session.id
- update! do |success, failure|
- success.html { redirect_to graph_instructions_users_path, notice: 'Успешно сохранено.' }
- success.js { render js: 'window.reload_page()', status: :ok }
- failure.html { render :graph_instructions_edit }
- failure.js { render js: 'alert("Нужно исправить ошибки:\n'+@user.errors.messages.values.flatten.join("\\n")+'")', status: :unprocessable_entity }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement