From 1c52835c1a69e4ba86517c7dadef3c5f21d00c60 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 13 Jun 2019 15:33:30 +0800 Subject: [PATCH] training: enroll update --- app/controllers/trainings_controller.rb | 9 +++++++-- app/views/trainings/enroll.html.erb | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/controllers/trainings_controller.rb b/app/controllers/trainings_controller.rb index 2f88d634..7b9164b5 100644 --- a/app/controllers/trainings_controller.rb +++ b/app/controllers/trainings_controller.rb @@ -108,7 +108,7 @@ class TrainingsController < ApplicationController @training = current_training || Training.new(params) @training.training_type = @training_type if @training_type == 3 - @training.research_field = params[:research_field].reject(&:blank?).uniq.join(",") + @training.research_field = params[:research_field].select(&:present?).uniq.join(",") @training.training_category = params[:training_category] end @training.openid = session[:wechat_open_id] @@ -126,7 +126,12 @@ class TrainingsController < ApplicationController return end - @training.update_attributes(params) + @training.assign_attributes(params) + if @training.training_type == 3 + @training.research_field = params[:research_field].select(&:present?).uniq.join(",") + @training.training_category = params[:training_category] + end + @training.save! redirect_to pay_training_path(id: @tag_id) end diff --git a/app/views/trainings/enroll.html.erb b/app/views/trainings/enroll.html.erb index 3acb9c3f..4def0abe 100644 --- a/app/views/trainings/enroll.html.erb +++ b/app/views/trainings/enroll.html.erb @@ -126,6 +126,8 @@

<%= @training_title %>

<%= form_for @training do |f| %> + <%= hidden_field_tag(:id, @tag_id) %> +

基本信息

  • 姓名 @@ -160,29 +162,29 @@ name="technical_title" value="<%#= @training.technical_title %>"/>-->
  • -

    培训类型

    + <% if @training_type == 3 %> +

    培训类型

  • 大数据方向 - + <%= radio_button_tag(:training_category, 'large_data', @training.training_category == 'large_data', id: 'type_1', class: 'magic-radio') %>
  • 人工智能方向 - + <%= radio_button_tag(:training_category, 'ai', @training.training_category == 'ai', id: 'type_2', class: 'magic-radio') %>
  • 大数据+人工智能方向 - + <%= radio_button_tag(:training_category, 'large_data_and_ai', @training.training_category == 'large_data_and_ai', id: 'type_3', class: 'magic-radio') %>
  • - <% if @training_type == 3 %>

    您的授课/研究领域(最少选1项)

  • 机器学习/深度学习