sinatra-backstage 0.2.4 → 0.2.5

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: b83633623dbf543d85186a19488832fcd7ec46bc
4
- data.tar.gz: 282236a8b6055e173583e34a4803df1855e51587
3
+ metadata.gz: 397d970726e29f697ee5e1bb07f1ad8b7b0b8db1
4
+ data.tar.gz: dde87549bc5cd998487ff7f9eaf49993ef25e360
5
5
  SHA512:
6
- metadata.gz: fa5d87d94f1c11f8af4aac892bfa9b0191fbe494cd1aa9a32b50019baff5a45ddb92d007f91d46e289b3cddf6016db2b5b0ee9732a6e45320088cce39e78f07f
7
- data.tar.gz: 83cdbaea1046c545090f9f62b4c3ea70543266ba7f942c9928c02f1a14c82f2057d84dc763134bf1524ceb4d3b6bc7d871a0aec9356c3bc4f5c9e6e932fd0ba7
6
+ metadata.gz: 2eb8be569d0c48b5e967e22efbfc754c372aeefd302c734acfccc0643a3006721dfa3136b3a359919d9efa1716aaf41afbf96b47050bb5b7705ffd8262c1d27a
7
+ data.tar.gz: 2ab08b3db038c11bccb82ee6c9b88b963f5b63580754e343e1b356b13f7d95d66a1dae6317146257d9fe0809368515cd15f7e1da35bc4f8cd7c2d2b410722503
@@ -36,10 +36,18 @@ module Sinatra
36
36
  begin
37
37
  attachment = params[:object].delete(field_name)
38
38
  attachment_attrs = get_attachment_attrs(attachment)
39
- klass.get!(id).send(field_name).update(
40
- attachment_attrs,
41
- attachment[:tempfile]
42
- )
39
+ child_obj = klass.get!(id).send(field_name)
40
+ if child_obj.nil?
41
+ params[:object][field_name] = child_klass.create(
42
+ attachment_attrs,
43
+ attachment[:tempfile]
44
+ )
45
+ else
46
+ child_obj.update(
47
+ attachment_attrs,
48
+ attachment[:tempfile]
49
+ )
50
+ end
43
51
  rescue DataMapper::SaveFailureError => e
44
52
  puts e.resource.errors.inspect
45
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-backstage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov