Merge pull request #63 from wayne5540/add-skip_cache_store_check-config

Add skip_cache_store_check configuration
This commit is contained in:
Jason Lee 2019-01-22 17:19:38 +08:00 committed by GitHub
commit 2a78655fec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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