Add skip_cache_store_check configuration

This commit is contained in:
Wayne 2018-05-17 14:23:58 +08:00
parent d0066b4b55
commit 66dbac9639
4 changed files with 6 additions and 1 deletions

View File

@ -41,6 +41,8 @@ RuCaptcha.configure do
 # 默认:会从 Rails 配置的 cache_store 里面读取相同的配置信息,并尝试用可以运行的方式,用于存储验证码字符
 # 但如果是 [:null_store, :memory_store, :file_store] 之类的,你可以通过下面的配置项单独给 RuCaptcha 配置 cache_store
 self.cache_store = :mem_cache_store
# 如果想要 disable cache_store 的 warning就设置为 truedefault false
# self.skip_cache_store_check = true
# Chars length, default: 5, allows: [3 - 7]
# self.length = 5
# enable/disable Strikethrough.

View File

@ -20,6 +20,7 @@ module RuCaptcha
@config.strikethrough = true
@config.outline = false
@config.expires_in = 2.minutes
@config.skip_cache_store_check = false
if Rails.application
@config.cache_store = Rails.application.config.cache_store

View File

@ -13,5 +13,7 @@ module RuCaptcha
attr_accessor :strikethrough
# outline style for hard mode, default: false
attr_accessor :outline
# skip_cache_store_check, default: false
attr_accessor :skip_cache_store_check
end
end

View File

@ -9,7 +9,7 @@ module RuCaptcha
mount RuCaptcha::Engine => '/rucaptcha'
end
RuCaptcha.check_cache_store!
RuCaptcha.check_cache_store! unless RuCaptcha.config.skip_cache_store_check
end
end
end