formnestic 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: 3dd0bc0425d77a4cd8462fca70aa96a62ce58074501803e19c99d5b502f89b4a
4
- data.tar.gz: 74dbbfd7b390e44634908d16b8a6cf6361732af0e518970bb6397de064394e45
3
+ metadata.gz: e281623f8c90a084c73a74df1ba4410e290e7718bbd309f0b7692dca5f5cbb39
4
+ data.tar.gz: 323e7995e366b181b816f23cbefc7eeb137607c5c9df9c5db6d6bdcea4a38b2f
5
5
  SHA512:
6
- metadata.gz: b4c62189e490379215453b77c315ddcbf262ec91ee9877287ef56e30a6703fbb20dc4f42e30265f2e9da285db2647d6da2066e5dd181ea204b14ba9a0571a6f3
7
- data.tar.gz: 3810b3d89604978d062945906a23666981bcc91930aee605200e8bc7408d316b3bc6e571a8ee90ace290f81586ba939ce07aa7411ea23b640670d966a94c33ac
6
+ metadata.gz: 5e533786817be4cc37a4c33cf8efa1ffb5c66e05f2ae7085f7133ee288e8c872d6a842f19d004001af8e56afc58ea376d4a577fe194f1c3235e98015c182a201
7
+ data.tar.gz: 2a4725a220dc4f31dd5e611c79b18b50173ec941372caa3048867d8416e12f53417dbfc277ee1af438c14f433947b50bf5c89f84b5b1020c16e8ef9d0066fd93
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.9
data/formnestic.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'formnestic'
8
- s.version = '1.0.8'
8
+ s.version = '1.0.9'
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ['James']
@@ -22,8 +22,23 @@ module Formnestic
22
22
  end
23
23
  end
24
24
 
25
- def formnestic_link_to_add_fields_with_content(record_or_name_or_array, *args, &block)
26
- new_object = object.class.reflect_on_association(record_or_name_or_array).klass.new
25
+ def formnestic_link_to_add_fields_with_content(
26
+ record_or_name_or_array, *args, &block
27
+ )
28
+ relationship = object.class.reflections[record_or_name_or_array.to_s]
29
+ if relationship.nil?
30
+ raise "#{record_or_name_or_array} is not a \
31
+ relationship of #{object.class}"
32
+ end
33
+
34
+ new_object =
35
+ if relationship.is_a?(
36
+ ActiveRecord::Reflection::HasManyReflection
37
+ )
38
+ object.public_send(record_or_name_or_array).build
39
+ else
40
+ relationship.klass.new
41
+ end
27
42
  options = args.dup.extract_options!
28
43
  options[:max_entry] ||= -1
29
44
  duplicate_args = args.dup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formnestic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - James