sadem_app/app/controllers/public/m_odr_reps_controller.rb
Nicolas Bally 1b82c04734 suite
2020-02-27 17:36:50 +01:00

64 lines
1.1 KiB
Ruby

# -*- encoding : utf-8 -*-
class Public::MOdrRepsController < ApplicationController
layout "public"
def new
@m_odr_rep = MOdrRep.new
end
def edit
@m_odr_rep = MOdrRep.find(params[:id])
end
def create
@m_odr_rep = MOdrRep.new(params.require(:m_odr_rep).permit!)
@m_odr = @m_odr_rep.m_odr
if @m_odr_rep.save
if mail_type = @m_odr.mail_types.where(:slug => "confirmation-inscription").first
mail = GeneralMails.general(:fr, mail_type, @m_odr_rep.particulars.first.email, {:arguments => {:numero_avoir => ""}, :m_odr => @m_odr})
mail.deliver
end
redirect_to thank_public_m_odr_rep_path(@m_odr_rep)
else
render :template => "public/m_odrs/show"
end
end
def thank
@m_odr_rep = MOdrRep.find(params[:id])
@m_odr = @m_odr_rep.m_odr
end
def update
@m_odr_rep = MOdrRep.find(params[:id])
if @m_odr_rep.update_attributes(params.require(:m_odr_rep).permit!)
else
render action: "edit"
end
end
end