So I have a basic sign up, sign in site with username and password. I don't want to use recaptcha and was wondering whether i can create my own? So have for example 'what colour is an orange'.
I was wondering how you could integrate this (if you can that is) into the form_for as it wouldn't be part of the @user object and throws an error.
Here is the controller
def new
@user = User.new
@captcha = Captcha.find(rand(1..3))
end
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
redirect_to root_path
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:username, :password, :release_pin)
end
Here is the view
<div class="sign-in-form">
<%= form_for @user do |form| %>
<div class="form-text">
<%= form.label :username %> <br>
<%= form.text_field :username %>
</div>
<br>
<div class="form-text">
<%= form.label :password %> <br>
<%= form.text_field :password %>
</div>
<br>
############## this here obviously throws
an error but this is the kind of thing i would want #########
<div class="form-text">
<p> <%[email protected]%> </p>
<%= form.text_field :captcha_answer %>
</div>
<div class="form-text">
<%= form.submit "Submit" %>
</div>
I've looked into nested forms but don't think that's the correct answer... but I could wrong as I'm only a beginner. thanks