Module: Sufia::ContactFormControllerBehavior

Included in:
ContactFormController
Defined in:
app/controllers/concerns/sufia/contact_form_controller_behavior.rb

Instance Method Summary collapse

Instance Method Details

#after_deliverObject



27
28
29
# File 'app/controllers/concerns/sufia/contact_form_controller_behavior.rb', line 27

def after_deliver
   return unless Sufia::Engine.config.enable_contact_form_delivery
end

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/concerns/sufia/contact_form_controller_behavior.rb', line 8

def create
  @contact_form = ContactForm.new(params[:contact_form])
  @contact_form.request = request
  # not spam and a valid form
  logger.warn "*** MARK ***"
  if @contact_form.deliver
    flash.now[:notice] = 'Thank you for your message!'
    after_deliver
    render :new
  else
    flash[:error] = 'Sorry, this message was not sent successfully. ' 
    flash[:error] << @contact_form.errors.full_messages.map { |s| s.to_s }.join(",")
    render :new
  end
rescue 
    flash[:error] = 'Sorry, this message was not delivered.'
    render :new
end

#newObject



4
5
6
# File 'app/controllers/concerns/sufia/contact_form_controller_behavior.rb', line 4

def new
  @contact_form = ContactForm.new
end