0
votes

I have simple app where users can register when they pass Human validation. For that my setup is like this:

Model:

   include Humanizer    
   attr_accessor :bypass_humanizer
   require_human_on :create, :unless => :bypass_humanizer

View:

  <%= f.label :humanizer_answer, @advertisement.humanizer_question %> 
  <%= f.hidden_field :humanizer_question_id %> 

This far everything works.

Also I want to allow admin user to register new users in ActiveAdmin panel.

As we now ActiveAdmin uses controller actions if we don't override them. Based on Humanizer documentation I have to set bypass_humanizer to true when I want to disable Human validation.

So I am overriding create action like this:

 controller do

    def create

      bypass_humanizer = true

      super
    end
  end

But it don't want to work as expected.

Any help on this ?

Thanks in advance for your time.

1

1 Answers

1
votes
ActiveAdmin.register Model do
  before_create do |model|
    model.bypass_humanizer = true
  end
end

Or you can place a hidden input with name bypass_humanizer and value true in the form.