accepts_nested_ids 0.1.1 → 0.1.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 +4 -4
- data/README.md +9 -7
- data/lib/accepts_nested_ids.rb +1 -1
- data/lib/accepts_nested_ids/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e07b9897436d630f866a0ff01ece3f4cc5b2e8
|
4
|
+
data.tar.gz: 330695c6af8fbf175c94a36d267dbffd16aa597a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6b41c816cb8b7103f05dbb3ab94909d986f9c132f67286e463b3c398a6fb991c3406ab54bddd287e5adbda89c7acf0fde52b3d8cc6574505194959467e17dc9
|
7
|
+
data.tar.gz: 2bb7068450d3243c9f88a5980445288aa6d29eab24d76970e06186c2de391aeacaf87bb6d8a694e6a53022f299ee7535d90e679ca27b4f4b8eaed77c3c7d7f24
|
data/README.md
CHANGED
@@ -18,11 +18,6 @@ class Project < ActiveRecord::Base
|
|
18
18
|
has_many :users, through: :project_users
|
19
19
|
validates :name, presence: true
|
20
20
|
end
|
21
|
-
|
22
|
-
class User < ActiveRecord::Base
|
23
|
-
has_many :project_users
|
24
|
-
has_many :projects, through: :project_users
|
25
|
-
end
|
26
21
|
```
|
27
22
|
|
28
23
|
When creating or updating a Project, you can select a list of User IDs from a select list. Great.
|
@@ -85,6 +80,8 @@ class Project < ActiveRecord::Base
|
|
85
80
|
has_many :users, through: :project_users
|
86
81
|
accepts_nested_ids_for :users
|
87
82
|
end
|
83
|
+
|
84
|
+
project.user_ids = [...]
|
88
85
|
```
|
89
86
|
|
90
87
|
### When your association has a custom name:
|
@@ -96,8 +93,12 @@ class Project < ActiveRecord::Base
|
|
96
93
|
has_many :included_users, through: :project_users, source: :user
|
97
94
|
accepts_nested_ids_for included_users: "User"
|
98
95
|
end
|
96
|
+
|
97
|
+
project.included_user_ids = [...]
|
99
98
|
```
|
100
99
|
|
100
|
+
When using a custom association name, you must specify the actual class name as a second arg, in this case "User".
|
101
|
+
|
101
102
|
### Mix and match as desired:
|
102
103
|
|
103
104
|
```ruby
|
@@ -108,9 +109,10 @@ class Project < ActiveRecord::Base
|
|
108
109
|
has_many :included_users, through: :project_users, source: :user
|
109
110
|
accepts_nested_ids_for :documents, included_users: "User"
|
110
111
|
end
|
111
|
-
```
|
112
112
|
|
113
|
-
|
113
|
+
project.document_ids = [...]
|
114
|
+
project.included_user_ids = [...]
|
115
|
+
```
|
114
116
|
|
115
117
|
## Development
|
116
118
|
|
data/lib/accepts_nested_ids.rb
CHANGED
@@ -24,7 +24,7 @@ module AcceptsNestedIds
|
|
24
24
|
# end
|
25
25
|
#
|
26
26
|
def save_nested_id_associations
|
27
|
-
self.class.nested_id_associations.each do |nested_id_association|
|
27
|
+
self.class.base_class.nested_id_associations.each do |nested_id_association|
|
28
28
|
if instance_variable_get("@#{nested_id_association.ids_attr}")
|
29
29
|
association_class = nested_id_association.class_name.constantize
|
30
30
|
ids = send(nested_id_association.ids_attr)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accepts_nested_ids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuval Kordov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|