Fix `maxlength` option of rucaptcha_input_tag method (#68)
This commit is contained in:
parent
738cdfd00d
commit
90484ceb34
|
@ -29,12 +29,15 @@ module RuCaptcha
|
||||||
# params:
|
# params:
|
||||||
# resource - [optional] a ActiveModel object, if given will add validation error message to object.
|
# resource - [optional] a ActiveModel object, if given will add validation error message to object.
|
||||||
# :keep_session - if true, RuCaptcha will not delete the captcha code session.
|
# :keep_session - if true, RuCaptcha will not delete the captcha code session.
|
||||||
|
# :captcha - if given, the value of it will be used to verify the captcha,
|
||||||
|
# if do not give or blank, the value of params[:_rucaptcha] will be used to verify the captcha
|
||||||
#
|
#
|
||||||
# exmaples:
|
# exmaples:
|
||||||
#
|
#
|
||||||
# verify_rucaptcha?
|
# verify_rucaptcha?
|
||||||
# verify_rucaptcha?(user, keep_session: true)
|
# verify_rucaptcha?(user, keep_session: true)
|
||||||
# verify_rucaptcha?(nil, keep_session: true)
|
# verify_rucaptcha?(nil, keep_session: true)
|
||||||
|
# verify_rucaptcha?(nil, captcha: params[:user][:captcha])
|
||||||
#
|
#
|
||||||
def verify_rucaptcha?(resource = nil, opts = {})
|
def verify_rucaptcha?(resource = nil, opts = {})
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
|
@ -54,7 +57,7 @@ module RuCaptcha
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure parama have captcha
|
# Make sure parama have captcha
|
||||||
captcha = (params[:_rucaptcha] || '').downcase.strip
|
captcha = (opts[:captcha] || params[:_rucaptcha] || '').downcase.strip
|
||||||
if captcha.blank?
|
if captcha.blank?
|
||||||
return add_rucaptcha_validation_error
|
return add_rucaptcha_validation_error
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module RuCaptcha
|
module RuCaptcha
|
||||||
VERSION = '2.3.1'
|
VERSION = '2.3.2'
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ module RuCaptcha
|
||||||
opts[:autocorrect] = 'off'
|
opts[:autocorrect] = 'off'
|
||||||
opts[:autocapitalize] = 'off'
|
opts[:autocapitalize] = 'off'
|
||||||
opts[:pattern] = '[a-zA-Z]*'
|
opts[:pattern] = '[a-zA-Z]*'
|
||||||
opts[:maxlength] = 5
|
|
||||||
opts[:autocomplete] = 'off'
|
opts[:autocomplete] = 'off'
|
||||||
|
opts[:maxlength] ||= 5
|
||||||
tag(:input, opts)
|
tag(:input, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue