Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

humanizer

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanizer

  • 2.7.0
  • Rubygems
  • Socket score

Version published
Maintainers
4
Created
Source

Humanizer

Humanizer is a very simple CAPTCHA method. It has a localized YAML file with questions and answers which is used to validate that the user is an actual human. Any model that includes ActiveModel::Validations should work. Our aim is to be database and mapper agnostic, so if it doesn't work for you, open an issue. Humanizer works with Rails 3–7.

Installation

Add humanizer to your Gemfile:

gem "humanizer"

Bundle and run the generator in terminal:

bundle
rails g humanizer

Advanced Installation

  • Install all locales: rails g humanizer --all-locales
  • Show available locales: rails g humanizer --show-locales
  • Install selected locales: rails g humanizer en fi de

Usage

  1. In your model, include Humanizer and add the #require_human_on method, example:
class User < ActiveRecord::Base
  include Humanizer
  require_human_on :create
end
  1. Ask the question in the form, example:
<%= f.label :humanizer_answer, @model.humanizer_question %>
<%= f.text_field :humanizer_answer %>
<%= f.hidden_field :humanizer_question_id %>
  1. If you are using attr_accessible, remember to whitelist :humanizer_answer and :humanizer_question_id.

  2. If you are using strong_parameters, remember to permit :humanizer_answer and :humanizer_question_id.

Configuration

Default translations can be found in config/locales/

You might want to add/change question and answer pairs. This can be easily done by adding/modifying entries in locales file.

Skipping validation

You might want to skip the humanizer validations on your tests or rails console.

You can just have a simple attribute on your model and use it to bypass the validation. Here's an example:

attr_accessor :bypass_humanizer
require_human_on :create, unless: :bypass_humanizer

Now when bypass_humanizer is true, validation will be skipped.

Reloading questions

In case you want to give your users the option to change the question, there's a #change_humanizer_question method to help you.

To make sure the current question doesn't get asked again, you can pass the current question id to the method. For example:

@user.change_humanizer_question(params[:user][:humanizer_question_id])

License

Humanizer is licensed under the MIT License, for more details see the LICENSE file.

Question/Answer Translations

  • English, Finnish and Portuguese translations by Kisko Labs
  • German by Sven Schwyn
  • Dutch by Joren De Groof
  • Brazilian Portuguese by Britto
  • Russian by Shark
  • Spanish by Juanjo Bazán
  • Polish by Maciek O
  • Italian by Alberto Vena
  • Chinese (Simplified) by Crane Jin

Contributors

CI Build Status

Build Status

FAQs

Package last updated on 19 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc