Hi
I am using simple_captcha. I have two models User and Staff.
Relation ship are
User has_one staff
staff belongs_to user
Now in the staff edit I have to include a captcha. I did like
<% form_for @user, :url => staff_url(@staff), :html => {:method => :put
} do |f|%>
<%= f.text_field :first_name,:maxlength => 50 %>
<%= show_simple_captcha :image_style => ‘random’,:distortion =>
‘medium’ %>
<%end %>
And in staff.rb
apply_simple_captcha :message => “Verification code does not match with
image.”
And in update action of of staff controller
def update
@staff = Staff.find(params[:id])
@user = @staff.user
if @staff.valid_with_captcha? and
@user.update_attributes(params[:user])
flash[:notice] = “check your mail "
redirect_to login_url
else
flash.now[:error] = @staff.errors.full_messages.join(”
")
#This I wrote deliberately
render :action => :edit
end
end
But even I put the correct captcha code and submit , it always shows
message
“Verification code does not match with image.”. Dont know why please
help
Note:
The params are like
{“user”=>{“first_name”=>“Tom”, “last_name”=>""}, “action”=>“update”,
“_method”=>“put”,
“authenticity_token”=>“0OWRFPssTgTqCUESex7LrJ2QQ7HWSiAQxtiMhQm/N1s=”,
“captcha”=>“PYESEZ”, “id”=>“10”, “controller”=>“staff”}
Thanks in advance
Tom