seminar2/app/controllers/admin/seminar_signups_controller.rb

54 lines
1.3 KiB
Ruby
Raw Normal View History

2016-06-29 06:57:45 +00:00
# encoding: utf-8
class Admin::SeminarSignupsController < OrbitAdminController
include Admin::SeminarsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
def initialize
super
@app_title = "seminar"
end
def edit
params[:controller] = "admin/seminars"
@seminar_signup = SeminarSignup.find(params[:id])
@seminar = SeminarMain.find(@seminar_signup.seminar_main_id)
@form_index = 0
end
def update
@seminar_signup = SeminarSignup.find(params[:id])
@seminar_signup.update_attributes(seminar_signup_params)
if !params[:seminar_signup_values].nil?
params[:seminar_signup_values].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[:id], field_value)
end
end
redirect_to "/admin/seminars/#{@seminar_signup.seminar_main_id}/seminar_signup"
end
def destroy
@seminar_signup = SeminarSignup.find(params[:id])
@seminar_main_id = @seminar_signup.seminar_main_id
@seminar_signup.destroy
redirect_to "/admin/seminars/#{@seminar_main_id}/seminar_signup"
end
private
def seminar_signup_params
params.require(:seminar_signup).permit!
end
end