From 18076d343de065181f0c03f4131647f254bfd624 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 4 Aug 2016 16:25:40 +0800 Subject: [PATCH] gotcha verification --- app/controllers/seminars_controller.rb | 27 ++++++++++++++------------ app/models/seminar_signup_value.rb | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 6a577b7..d513de4 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -135,24 +135,27 @@ class SeminarsController < ApplicationController @signup = SeminarSignup.where(email: params[:seminar_signup][:email], seminar_main_id: params[:seminar_signup][:seminar_main_id] ).first @seminar_signup = SeminarSignup.new(seminar_signup_params) + if gotcha_valid? + if @signup.blank? && @seminar_signup.save + # if gotcha_valid? && @seminar_signup.save - if @signup.blank? && @seminar_signup.save - # if gotcha_valid? && @seminar_signup.save + if !params[:seminar_signup_values].nil? + seminar_signup_values_params.each_with_index do |r,i| + field_value = r.last[:id].present? + @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) + end + end - if !params[:seminar_signup_values].nil? - seminar_signup_values_params.each_with_index do |r,i| - field_value = r.last[:id].present? - @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) + redirect_to "#{params[:referer_url]}/?method=signup_ok" + else + if !@signup.blank? + redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' + else + redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') end end - - redirect_to "#{params[:referer_url]}/?method=signup_ok" else - if !@signup.blank? - redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' - else redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') - end end end diff --git a/app/models/seminar_signup_value.rb b/app/models/seminar_signup_value.rb index c1a648f..9175137 100644 --- a/app/models/seminar_signup_value.rb +++ b/app/models/seminar_signup_value.rb @@ -158,7 +158,7 @@ class SeminarSignupValue @seminar_signup_field_value.update(field_value_param) rescue nil @seminar_signup_field_value.save rescue nil else - @seminar_signup_field_value = member.seminar_signup_values.build(field_value_param) #rescue nil + @seminar_signup_field_value = member.seminar_signup_values.build(field_value_param) rescue nil @seminar_signup_field_value.save end return @seminar_signup_field_value