matthutchinson / acts_as_textcaptcha

Text-based logic question captcha's for Rails 🚫🤖

Home Page:https://acts-as-textcaptcha.hiddenloop.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mongoid implementation

beardenj opened this issue · comments

commented

How does one get this working using a MongoDB and the Mongoid gem?

This gem has been built with ActiveRecord and ActiveModel in mind, however you can use it with regular Rails classes, provided you include the relevant ActiveModel includes (Conversion and Validation) in your class, as shown here in the tests;

https://github.com/matthutchinson/acts_as_textcaptcha/blob/master/test/test_models.rb

class Contact
  # non active record object (symbol keys), no API used
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend  ActsAsTextcaptcha::Textcaptcha
  acts_as_textcaptcha :questions   => [{ :question => 'one+1', :answers => "2,two,апельсин" }],
                      :bcrypt_salt => '$2a$10$j0bmycH.SVfD1b5mpEGPpe'
end