Sha256: 350e28a27b57e1c9571628184f52c59102af1aa6f4b2fada4675bbce0d07ca36

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

module Spina
  class InquiriesController < Spina::ApplicationController

    before_filter :setup_negative_captcha, only: [:create]

    def create
      @inquiry = Inquiry.new(@captcha.values)

      if @inquiry.save
        @inquiry.spam! unless @captcha.valid?
        InquiryMailer.inquiry(@inquiry).deliver unless @inquiry.spam
      else
        flash[:notice] = @captcha.error if @captcha.error
        render :failed
      end
    end

    private

    def setup_negative_captcha
      @captcha = NegativeCaptcha.new(
        secret: Engine.config.NEGATIVE_CAPTCHA_SECRET,
        spinner: request.remote_ip,
        fields: [:email, :message, :name],
        params: params
      )
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spina-0.7.3 app/controllers/spina/inquiries_controller.rb
spina-0.7.2 app/controllers/spina/inquiries_controller.rb