Sha256: 837cc7a49cb7574bd1d738fdaf93ead3f7b321f47652e09f677a4e151b5dc38c

Contents?: true

Size: 832 Bytes

Versions: 4

Compression:

Stored size: 832 Bytes

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

  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

  private

  def custom_callback
    redirect_to new_topic_path
  end

  def custom_timestamp_callback
    redirect_to root_path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
invisible_captcha-0.9.3 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.9.2 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.9.1 spec/dummy/app/controllers/topics_controller.rb
invisible_captcha-0.9.0 spec/dummy/app/controllers/topics_controller.rb