Merge pull request #409 from hennevogel/refactor-conference-contact

Refactor conference contact
This commit is contained in:
Henne Vogelsang 2014-08-06 11:56:14 +02:00
commit 850beb72e1
22 changed files with 219 additions and 59 deletions

View file

@ -0,0 +1,44 @@
class Admin::ContactsController < ApplicationController
before_action :set_conference
before_action :set_contact, only: [:show, :edit, :update, :destroy]
# GET /:conference/contact
def show
end
# GET /:conference/contact/edit
def edit
end
# PATCH/PUT /:conference/contact
def update
if @contact.update(contact_params)
redirect_to admin_conference_contact_path, notice: 'Contact details were successfully updated.'
else
render :edit
end
end
# DELETE /:conference/contact
def destroy
@contact.destroy
redirect_to admin_conference_contacts_url, notice: 'Contact details were successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_contact
@contact = @conference.contact
end
def set_conference
@conference = Conference.find_by(short_title: params[:conference_id])
end
# Only allow a trusted parameter "white list" through.
def contact_params
# params.require(:contact).permit(:social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public)
params[:contact]
end
end

View file

@ -37,7 +37,7 @@ class ConferenceRegistrationController < ApplicationController
if regs.where(email: user.email).count == 0
redirect_to(register_conference_path(id: conference.short_title),
alert: "This code is already in use.
Please contact #{conference.contact_email} for assistance.")
Please contact #{conference.contact.email} for assistance.")
return
end
end