training: enroll update

dev_trainings
p31729568 6 years ago
parent 7d6c272f34
commit 1c52835c1a

@ -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

@ -126,6 +126,8 @@
<div>
<p class="collegeInfo"><%= @training_title %></p>
<%= form_for @training do |f| %>
<%= hidden_field_tag(:id, @tag_id) %>
<p class="subtitle">基本信息</p>
<li class="clearfix infoBar">
<span class="left_tag fl">姓名</span>
@ -160,29 +162,29 @@
name="technical_title"
value="<%#= @training.technical_title %>"/>-->
</li>
<p class="subtitle">培训类型</p>
<% if @training_type == 3 %>
<p class="subtitle">培训类型</p>
<li class="clearfix infoBar">
<span class="left_tag fl">大数据方向</span>
<span class="fr">
<input type="radio" name="training_category" value="large_data" id="type_1" class="magic-radio">
<%= radio_button_tag(:training_category, 'large_data', @training.training_category == 'large_data', id: 'type_1', class: 'magic-radio') %>
<label for="type_1" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">人工智能方向</span>
<span class="fr">
<input type="radio" name="training_category" value="ai" id="type_2" class="magic-radio">
<%= radio_button_tag(:training_category, 'ai', @training.training_category == 'ai', id: 'type_2', class: 'magic-radio') %>
<label for="type_2" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">大数据+人工智能方向</span>
<span class="fr">
<input type="radio" name="training_category" value="large_data_and_ai" id="type_3" 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') %>
<label for="type_3" style="top:8px">&nbsp;</label>
</span>
</li>
<% if @training_type == 3 %>
<p class="subtitle">您的授课/研究领域最少选1项</p>
<li class="clearfix infoBar">
<span class="left_tag fl">机器学习/深度学习</span>

Loading…
Cancel
Save