Removes simple captcha attributes

When I used 3 pearls of the "simple-captcha" project ( https://github.com/galetahub/simple-captcha ) in my rails , I found an error by calling the function <% = show_simple_captcha%>:

Can't mass-assign protected attributes: key
+4
source share
3 answers

THIS WORKS FOR ME:

Put this in the initializer (config / initializers / simple_captcha.rb)

Rails.configuration.to_prepare do
  class SimpleCaptcha::SimpleCaptchaData < ::ActiveRecord::Base
    attr_protected
  end
end
+2
source

I was getting this error because I used form-based view code:

<%= f.simple_captcha(:label => "Enter letters from image above", :placeholder => "") %>

, , , captcha. . ( , .):

<%= show_simple_captcha(:label => "Enter letters from image above",
                        :placeholder => "") %>
0

Solution: use an alternative repository for rails 3 applications through

gem 'simple_captcha', :git => 'git://github.com/rubymaniac/simple-captcha'
-2
source

Source: https://habr.com/ru/post/1526638/


All Articles