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 +4 -4
- data/lib/sinatra/backstage/stored_file/stored_file_routes.rb +12 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397d970726e29f697ee5e1bb07f1ad8b7b0b8db1
|
4
|
+
data.tar.gz: dde87549bc5cd998487ff7f9eaf49993ef25e360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
40
|
-
|
41
|
-
|
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
|