當我在軌使用3項目寶石 「簡單的captcha」(https://github.com/galetahub/simple-captcha)我通過調用函數<%= show_simple_captcha%>有鑑於錯誤:Rails的簡單驗證碼屬性
Can't mass-assign protected attributes: key
當我在軌使用3項目寶石 「簡單的captcha」(https://github.com/galetahub/simple-captcha)我通過調用函數<%= show_simple_captcha%>有鑑於錯誤:Rails的簡單驗證碼屬性
Can't mass-assign protected attributes: key
解決方案: 使用通過
gem 'simple_captcha', :git => 'git://github.com/rubymaniac/simple-captcha'
鋼軌3個應用程序替代庫這爲我工作:
認沽THI S IN的初始值設定(配置/初始化/ simple_captcha.rb)
Rails.configuration.to_prepare do
class SimpleCaptcha::SimpleCaptchaData < ::ActiveRecord::Base
attr_protected
end
end
因爲我用基於表單的視圖代碼我正在此錯誤:
<%= f.simple_captcha(:label => "Enter letters from image above", :placeholder => "") %>
我認爲這是由引起f引用我的用戶模型,其中 不引用驗證碼屬性。我放棄了表單基礎,並且問題 消失了。 (試過以上兩種解決方案,但在我的情況下它們不起作用):
<%= show_simple_captcha(:label => "Enter letters from image above",
:placeholder => "") %>