Sha256: 98f50b843251044ccc5919f08d6bb34a015b30c3489a3c8f08821c841b119350

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 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: Spina.config.NEGATIVE_CAPTCHA_SECRET,
        spinner: request.remote_ip,
        fields: [:email, :message, :name],
        params: params
      )
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spina-0.8.3 app/controllers/spina/inquiries_controller.rb
spina-0.8.2 app/controllers/spina/inquiries_controller.rb
spina-0.8.1 app/controllers/spina/inquiries_controller.rb
spina-0.8.0 app/controllers/spina/inquiries_controller.rb