Registration form working

This commit is contained in:
Godwin
2014-03-09 21:18:31 -06:00
parent 5e9e3d5fec
commit 4b79de7a24
4 changed files with 28 additions and 33 deletions
+17 -1
View File
@@ -34,12 +34,28 @@ class ConferencesController < ApplicationController
# PATCH/PUT /conferences/1
def update
if params[:register]
registration = ConferenceRegistration.find_by(:user_id => current_user.id, :conference_id => @conference.id)
if registration
registration.conference_registration_responses.destroy_all
else
registration = ConferenceRegistration.new(user_id: current_user.id, conference_id: @conference.id, is_attending: params[:is_attending])
end
data = Hash.new
params.each do |key, value|
matches = /^field_(\d+)(_(\d+|other))?/.match(key)
if matches
x
if matches[3] == nil
data[matches[1]] = value
else
data[matches[1]] ||= Hash.new
data[matches[1]][matches[3]] = value
end
end
end
data.each do |key, value|
registration.conference_registration_responses << ConferenceRegistrationResponse.new(registration_form_field_id: key.to_i, data: value.to_json.to_s)
end
registration.save!
render action: 'show'
elsif @conference.update(conference_params)
redirect_to @conference, notice: 'Conference was successfully updated.'
-3
View File
@@ -12,8 +12,6 @@
= field f, :poster, :image_field, @conference.poster_url
= field f, :cover, :image_field, @conference.cover_url
.columns.medium-8
=# f.fields_for :conference_type do |c|
=# field c, :id, :text_field
= field f, :conference_type_id, :collection_select, ConferenceType.all, attrs: [:id, :title]
.row
.columns.small-6
@@ -21,7 +19,6 @@
.columns.small-6
= field f, :end_date, :date_field
= field f, :workshop_schedule_published, :check_box
=# field f, :registration_open, :check_box
= field f, :meals_provided, :check_box
= field f, :meal_info, :text_area
= field f, :travel_info, :text_area