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

Error undefined method `spam_question' for nil:NilClass

dinooz opened this issue · comments

Hey Dude... got my key... follow the instructions and got an error in rails...

undefined method `spam_question' for nil:NilClass

I did create my key from the website...
377mqbg9abcwk84wsk0soosc43ghrhhs

Update the Gem File
Lets Add TextCaptcha
gem 'acts_as_textcaptcha'

irb
require 'bcrypt';BCrypt::Engine.generate_salt
=> "$2a$10$qPsPPPOTzq.X3nuWZM9mOO"

Is this Engine need to be the name of the model to protect ? I din't think so....

I include the code in the form...

Is a form _form.html.erb generated by scaffold...

<%= textcaptcha_fields(f) do %>
<%= f.label :spam_answer, @comment.spam_question %>
<%= f.text_field :spam_answer, :value => '' %>
<% end %>

but not sure if is going to conflict with the other form...

The main question is it necesary to create another text field in the model to protect to allocate the spam_question and spam_answer ?

THX Dino.

It looks like (from your error) that the @comment variable is not present in your view, but without seeing more code, (controller/model for example) I can't say whats wrong for sure. Check that somewhere in your controller action for adding comments you have something like;

def new
  @comment = Comment.new
  @comment.textcaptcha
end