accepts_nested_ids 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 777e9c1455b2e3afe447967dd9bfef1a46e90647
4
- data.tar.gz: a278c2a289613f95afbf230587b0729cafd21505
3
+ metadata.gz: 74e07b9897436d630f866a0ff01ece3f4cc5b2e8
4
+ data.tar.gz: 330695c6af8fbf175c94a36d267dbffd16aa597a
5
5
  SHA512:
6
- metadata.gz: 23c3f785a49ac7c4e4259fc1b484ffa4293cb403dfc780cacb77778f5c67a47f91c689397980aa28b87acfba20dc507151b64b0019a1a62604f9e6349193ba04
7
- data.tar.gz: c42cbcf9c416117c52118ae8ca757dfab76b6c3a51e4e8a5d66dc310c9ca5b0fd514e8bd4ec03a9728f7df095faec822b43fc114f5faeab1232af1b6c4d00bc6
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
- You can now comfortably set `document_ids` or `user_ids` on a `Project` without making a mess of things.
113
+ project.document_ids = [...]
114
+ project.included_user_ids = [...]
115
+ ```
114
116
 
115
117
  ## Development
116
118
 
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module AcceptsNestedIds
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-07-27 00:00:00.000000000 Z
12
+ date: 2015-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport