mongoid-direct-s3-upload 0.1.2 → 0.1.3

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: 7c82597a829e6f5936ccfb54700eea7736e157d5
4
- data.tar.gz: c6631d455e530188f8fd1f3fc4df84cbbdb198cd
3
+ metadata.gz: 1e0d2641b4ce3a70b19f1eb4ca23dfbcc3363052
4
+ data.tar.gz: e44ee934851643232aca8a968beba504c2d883af
5
5
  SHA512:
6
- metadata.gz: bd69b6ef56e78c94e0ee3ae35edf8db8899502745b69f46ad5a0a15d55332d7bcda6eb57a820a3dda1cfed1489e49d14da09155436f2bb7101f1f7b792084468
7
- data.tar.gz: a4c2d45033dbd5750a9113c8dd2a2aa073e304b78ed671419fbd5a3aee30e9c5bda15ce788208d77a051f60b3c618facbe7d04c35dd153c89be22b70b0e53a08
6
+ metadata.gz: acef0474e52f116a3e407696dc8db7fcf58182a4a9904e4b22c4302c252c7ff1620610ed2811a612d2745b129354a5798b970a6f29158549b3164702138fbef6
7
+ data.tar.gz: 8544fb25b876bb031084308f05956afe623a7ed8d4704bed3cd6e85dbe3678092934f7a468be025942738dd6fdbe1814b07d1746f62e52c8eb90761b3a4d8aff
data/README.md CHANGED
@@ -85,7 +85,6 @@ to learn how to lock it down further.
85
85
  ## Installation
86
86
 
87
87
  * Add `gem "mongoid-direct-s3-upload"` to your Gemfile and run `bundle`.
88
- * Add migrations to your app with `rake s3_relay:install:migrations db:migrate`.
89
88
  * Add `mount S3Relay::Engine => "/s3_relay"` to the top of your routes file.
90
89
  * Add `require s3_relay` to your JavaScript manifest.
91
90
  * [Optional] Add `require s3_relay` to your Style Sheet manifest.
@@ -238,11 +237,11 @@ end
238
237
 
239
238
  ## Contributing
240
239
 
241
- 1. [Fork it](https://github.com/kjohnston/s3_relay/fork)
240
+ 1. [Fork it](https://github.com/hartator/mongoid-direct-s3-upload/fork)
242
241
  2. Create your feature branch (`git checkout -b my-new-feature`)
243
242
  3. Commit your changes (`git commit -am 'Added some feature'`)
244
243
  4. Push to the branch (`git push origin my-new-feature`)
245
- 5. [Create a Pull Request](https://github.com/kjohnston/s3_relay/pull/new)
244
+ 5. [Create a Pull Request](https://github.com/hartator/mongoid-direct-s3-upload/pull/new)
246
245
 
247
246
  ## License
248
247
 
@@ -15,7 +15,7 @@ class S3Relay::UploadsController < ApplicationController
15
15
  private_url: @upload.private_url,
16
16
  parent_type: @upload.parent_type,
17
17
  parent_id: @upload.parent_id,
18
- user_id: user_attrs[:user_id]
18
+ user_id: BSON::ObjectId(user_attrs[:user_id])
19
19
  }
20
20
  render json: data, status: 201
21
21
  else
@@ -32,20 +32,10 @@ class S3Relay::UploadsController < ApplicationController
32
32
  end
33
33
 
34
34
  def parent_attrs
35
- type = params[:parent_type].try(:classify)
36
- id = params[:parent_id]
37
-
38
- return {} unless type.present? && id.present? &&
39
- parent = type.constantize.find(id)
40
-
41
- begin
42
- public_send(
43
- "#{type.underscore.downcase}_#{params[:association]}_params",
44
- parent
45
- )
46
- rescue NoMethodError
47
- { parent: parent }
48
- end
35
+ {
36
+ parent_type: params[:parent_type].try(:classify),
37
+ parent_id: BSON::ObjectId(params[:parent_id])
38
+ }
49
39
  end
50
40
 
51
41
  def upload_attrs
@@ -4,9 +4,9 @@ module S3Relay
4
4
  include Mongoid::Document
5
5
 
6
6
  field :uuid
7
- field :user_id, type: Integer
7
+ field :user_id, type: BSON::ObjectId
8
8
  field :parent_type, type: String
9
- field :parent_id, type: Integer
9
+ field :parent_id, type: BSON::ObjectId
10
10
  field :upload_type, type: String
11
11
  field :filename, type: String
12
12
  field :content_type, type: String
@@ -2,6 +2,7 @@ module S3Relay
2
2
  module Model
3
3
 
4
4
  def s3_relay(attribute, has_many=false)
5
+
5
6
  upload_type = attribute.to_s.classify
6
7
 
7
8
  if has_many
@@ -13,7 +14,7 @@ module S3Relay
13
14
  parent_type: self.class.to_s,
14
15
  parent_id: self.id,
15
16
  upload_type: upload_type
16
- )
17
+ ).to_a
17
18
  end
18
19
  else
19
20
  has_one attribute, as: :parent, class_name: "S3Relay::Upload"
@@ -1,3 +1,3 @@
1
1
  module S3Relay
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-direct-s3-upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hartator
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails