Skip to content

Commit

Permalink
adds a configuration option to enable/disable all remote (ajax) valid…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
bwlang authored and grimen committed Nov 19, 2009
1 parent 21b3f88 commit ad1d901
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions generators/validatious/templates/initializer.rb
Expand Up @@ -2,4 +2,5 @@

if defined?(::ValidatiousOnRails)
::ValidatiousOnRails.client_side_validations_by_default = true
::ValidatiousOnRails.remote_validations_enabled = false
end
4 changes: 3 additions & 1 deletion lib/validatious-on-rails.rb
Expand Up @@ -21,9 +21,11 @@ def initialize(message)

@@verbose = ::Object.const_defined?(:RAILS_ENV) ? (::RAILS_ENV.to_sym == :development) : true
@@client_side_validations_by_default = true
@@remote_validations_enabled = false

mattr_accessor :verbose,
:client_side_validations_by_default
:client_side_validations_by_default,
:remote_validations_enabled

# Logging helper: Internal debug-logging for the plugin.
#
Expand Down
8 changes: 8 additions & 0 deletions lib/validatious-on-rails/validatious/remote_validator.rb
Expand Up @@ -25,6 +25,14 @@ def fn
})
end

def to_js
if ::ValidatiousOnRails.remote_validations_enabled
super
else
"// remote validations disabled"
end
end

class << self

# Perform the actual validation on the server-side.
Expand Down

0 comments on commit ad1d901

Please sign in to comment.