# -*- encoding : utf-8 -*- class Public::RegistrantsController < ApplicationController layout "public" def create @registrant = Registrant.new(params.require(:registrant).permit!) test = Registrant.find_by_email(@registrant.email) if test @registrant = test General.confirm_email(@registrant).deliver else if @registrant.save General.confirm_email(@registrant).deliver else render :action => :new end end end def edit @registrant = Registrant.find_by_token(params[:id]) if @registrant @registrant.destroy redirect_to root_path, :notice => "L'adresse mail #{@registrant.email} à bien été supprimée de notre fichier." else redirect_to root_path, :notice => "Votre adresse mail ne figure pas dans notre fichier." end end def email_validation @registrant = Registrant.find_by_token(params[:id]) if @registrant @registrant.enabled = true @registrant.save redirect_to root_path, :notice => "Merci ! Votre inscription est confirmée, vous recevrez désormais notre newsletter !" else redirect_to root_path, :notice => "Votre adresse mail ne figure pas dans notre fichier." end end end