cocoon 1.0.20 → 1.0.21
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.
- data/README.markdown +2 -2
- data/VERSION +1 -1
- data/cocoon.gemspec +2 -2
- data/lib/cocoon/view_helpers.rb +7 -3
- data/spec/cocoon_spec.rb +7 -2
- data/spec/dummy/app/models/comment.rb +2 -0
- metadata +4 -4
data/README.markdown
CHANGED
@@ -105,8 +105,8 @@ Inside our `projects/_form` partial we then write:
|
|
105
105
|
= render 'task_fields', :f => task
|
106
106
|
.links
|
107
107
|
= link_to_add_association 'add task', f, :tasks
|
108
|
-
-f.
|
109
|
-
= f.submit
|
108
|
+
-f.actions do
|
109
|
+
= f.action :submit
|
110
110
|
````
|
111
111
|
|
112
112
|
and inside the `_task_fields` partial we write:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.21
|
data/cocoon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cocoon"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.21"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-05-09"
|
13
13
|
s.description = "Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven."
|
14
14
|
s.email = "nathan@dixis.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/cocoon/view_helpers.rb
CHANGED
@@ -84,9 +84,13 @@ module Cocoon
|
|
84
84
|
# will create new Comment with author "Admin"
|
85
85
|
|
86
86
|
def create_object(f, association)
|
87
|
-
assoc
|
88
|
-
|
89
|
-
|
87
|
+
assoc = f.object.class.reflect_on_association(association)
|
88
|
+
|
89
|
+
if assoc.collection?
|
90
|
+
f.object.send(association).build
|
91
|
+
else
|
92
|
+
f.object.send("build_#{association}")
|
93
|
+
end
|
90
94
|
end
|
91
95
|
|
92
96
|
def get_partial_path(partial, association)
|
data/spec/cocoon_spec.rb
CHANGED
@@ -175,11 +175,16 @@ describe Cocoon do
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
context "
|
179
|
-
it "should create correct association" do
|
178
|
+
context "create_object" do
|
179
|
+
it "should create correct association with conditions" do
|
180
180
|
result = @tester.create_object(@form_obj, :admin_comments)
|
181
181
|
result.author.should == "Admin"
|
182
182
|
end
|
183
|
+
|
184
|
+
it "should create correct association for belongs_to associations" do
|
185
|
+
result = @tester.create_object(stub(:object => Comment.new), :post)
|
186
|
+
result.should be_a Post
|
187
|
+
end
|
183
188
|
end
|
184
189
|
|
185
190
|
context "get_partial_path" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 21
|
10
|
+
version: 1.0.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Van der Auwera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|