rapscallion 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4faa2b9c0fb094df19be7f5660885e1f3df7333
|
4
|
+
data.tar.gz: f8ea9dddf622c0e2b376a4d1d4d75723d262eaca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd52ff49f1bfcbd024308a1e41b26d67c46bf2086f984b6f12a8dc356f3308e9e1e03a3f96012c45caf2d5ffeb8c5a1e60345293e20b285414f4fb69d373866e
|
7
|
+
data.tar.gz: f6d393b835ac74b6bba5d01a99ab8c62c0ce9a7e58d5f526098340ccd532c52971ce6ab0e4ba163c8122ab42e6d80a3f98b058c922432b470a4c7c9589753ca9
|
data/README.md
CHANGED
@@ -22,6 +22,12 @@ View example with Simple Form:
|
|
22
22
|
= f.input :username, input_html: {class: 'rapscallion'}
|
23
23
|
```
|
24
24
|
|
25
|
+
When validating an existing record (for example to avoid uniqueness validation problems):
|
26
|
+
|
27
|
+
``` haml
|
28
|
+
= simple_form_for @thing, html: {data: {existing_record: @thing.id}} do |f|
|
29
|
+
```
|
30
|
+
|
25
31
|
Model:
|
26
32
|
|
27
33
|
``` ruby
|
@@ -45,6 +45,11 @@ $(document).on('blur', '.rapscallion', function(){
|
|
45
45
|
|
46
46
|
validation_data[confirmation_field] = confirmation_value;
|
47
47
|
|
48
|
+
/* existing record? */
|
49
|
+
if(form.data('existing-record') != undefined) {
|
50
|
+
validation_data['existing_record'] = form.data('existing-record');
|
51
|
+
};
|
52
|
+
|
48
53
|
/* do ajax request */
|
49
54
|
$.ajax({
|
50
55
|
type: "POST",
|
@@ -4,7 +4,13 @@ module Rapscallion
|
|
4
4
|
|
5
5
|
def create
|
6
6
|
klass = params[:klass].camelize.constantize
|
7
|
-
|
7
|
+
|
8
|
+
if params[:existing_record].present?
|
9
|
+
item = klass.find(params[:existing_record])
|
10
|
+
else
|
11
|
+
item = klass.new
|
12
|
+
end
|
13
|
+
|
8
14
|
field = params[:attr]
|
9
15
|
value = params[:field_val]
|
10
16
|
item.send("#{field}=", value)
|
data/lib/rapscallion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapscallion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gordon Isnor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|