Sha256: e0efa3a9bce0d7150d6e4025c13205546d9f109047eb1e4f8285999dc0a797a4

Contents?: true

Size: 899 Bytes

Versions: 6

Compression:

Stored size: 899 Bytes

Contents

module Sufia
  module ContactFormControllerBehavior
    def new
      @contact_form = ContactForm.new
    end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 app/controllers/concerns/sufia/contact_form_controller_behavior.rb
sufia-7.0.0.beta3 app/controllers/concerns/sufia/contact_form_controller_behavior.rb
sufia-7.0.0.beta2 app/controllers/concerns/sufia/contact_form_controller_behavior.rb
sufia-7.0.0.beta1 app/controllers/concerns/sufia/contact_form_controller_behavior.rb
sufia-6.6.1 app/controllers/concerns/sufia/contact_form_controller_behavior.rb
sufia-6.6.0 app/controllers/concerns/sufia/contact_form_controller_behavior.rb