Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #465 from maintux/master

remote validations
  • Loading branch information...
commit a6a515504520e9925ca63524ae9854168163283e 2 parents 7145c84 + 29e9e55
Brian Cardarella authored
5 coffeescript/rails.validations.coffee
@@ -385,8 +385,11 @@ window.ClientSideValidations.validators =
385 385 name = options['class'] + '[' + name.split('[')[1] if options['class']
386 386 data[name] = element.val()
387 387
  388 + unless ClientSideValidations.remote_validators_prefix?
  389 + ClientSideValidations.remote_validators_prefix = ""
  390 +
388 391 if jQuery.ajax({
389   - url: '/validators/uniqueness',
  392 + url: "#{ClientSideValidations.remote_validators_prefix}/validators/uniqueness",
390 393 data: data,
391 394 async: false
392 395 cache: false
2  lib/client_side_validations/action_view/form_helper.rb
@@ -123,7 +123,7 @@ def client_side_form_settings(object, options)
123 123 end
124 124
125 125 content_tag(:script) do
126   - "//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['#{var_name}'] = #{builder.client_side_form_settings(options, self).merge(:validators => 'validator_hash').to_json};\n//]]>".html_safe
  126 + "//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.remote_validators_prefix==undefined)window.ClientSideValidations.remote_validators_prefix='#{(root_path||"").sub(/(\/)+$/,'')}';if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['#{var_name}'] = #{builder.client_side_form_settings(options, self).merge(:validators => 'validator_hash').to_json};\n//]]>".html_safe
127 127 end
128 128 end
129 129 end
2  test/action_view/cases/helper.rb
@@ -137,7 +137,7 @@ def whole_form(action = "http://www.example.com", id = nil, html_class = nil, op
137 137 end
138 138
139 139 def build_script_tag(html, id, validators)
140   - (html || "") + %Q{<script>//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['#{id}'] = #{client_side_form_settings_helper.merge(:validators => validators).to_json};\n//]]></script>}
  140 + (html || "") + %Q{<script>//<![CDATA[\nif(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.remote_validators_prefix==undefined)window.ClientSideValidations.remote_validators_prefix='';if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['#{id}'] = #{client_side_form_settings_helper.merge(:validators => validators).to_json};\n//]]></script>}
141 141 end
142 142
143 143 protected
5 vendor/assets/javascripts/rails.validations.js
@@ -528,8 +528,11 @@
528 528 name = options['class'] + '[' + name.split('[')[1];
529 529 }
530 530 data[name] = element.val();
  531 + if (ClientSideValidations.remote_validators_prefix == null) {
  532 + ClientSideValidations.remote_validators_prefix = "";
  533 + }
531 534 if (jQuery.ajax({
532   - url: '/validators/uniqueness',
  535 + url: "" + ClientSideValidations.remote_validators_prefix + "/validators/uniqueness",
533 536 data: data,
534 537 async: false,
535 538 cache: false

0 comments on commit a6a5155

Please sign in to comment.
Something went wrong with that request. Please try again.