Sha256: 3fb961628c17c5faefe086ea7b2fff8b013dbdf63f485a440f48678496c673dd

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

class TopicsController < ApplicationController
  invisible_captcha honeypot: :subtitle, only: :create

  invisible_captcha honeypot: :subtitle, only: :update,
                              on_spam: :custom_callback,
                              on_timestamp_spam: :custom_timestamp_callback

  invisible_captcha honeypot: :subtitle, only: :publish, timestamp_threshold: 2

  invisible_captcha honeypot: :subtitle, only: :copy, timestamp_enabled: false

  def index
    redirect_to new_topic_path
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(params[:topic])

    if @topic.valid?
      redirect_to new_topic_path(context: params[:context]), notice: 'Topic valid!'
    else
      render action: 'new'
    end
  end

  def update
  end

  def publish
    redirect_to new_topic_path
  end

  def copy
    @topic = Topic.new(params[:topic])

    if @topic.valid?
      redirect_to new_topic_path(context: params[:context]), notice: 'Success!'
    else
      render action: 'new'
    end
  end

  private

  def custom_callback
    redirect_to new_topic_path
  end

  def custom_timestamp_callback
    head(204)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
invisible_captcha-2.0.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-1.1.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-1.0.1 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-1.0.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.13.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.12.2 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.12.1 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.12.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.11.0 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.10.0 spec/dummy/app/controllers/topics_controller.rb