active_storage_base64 0.1.3 → 0.1.4

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: 3a8fb507b829cbc1391e67980bb733767fb33273921af4bace259c2a7af9fcab
4
- data.tar.gz: '059a2c3c923ecbad36c6f26f1a97f4bca2d0b66fe373702e7858a3b24c9cd4e5'
3
+ metadata.gz: a89024b9798e7c3adfef588638e62623c6891eb52ad0d6ba2aebfa1a603dd6ce
4
+ data.tar.gz: 405e6a9a85a3b3755e06e8f4b958d5731d0558b73bc41ff71dc048dcd5b630c3
5
5
  SHA512:
6
- metadata.gz: 6e6756f8888101cbc476e09fd42eacf331b784249d51f4a8abd313b516848135bdb5f27b35a51ac5b1c7726150ca71e2f2f57c11e23c3580d2afce62b3cb32f4
7
- data.tar.gz: af8702891ae2527294e8f9e2de7623f938b892a6347bb7b916094df54e338f8892468ba061506b5a92c1423075a025301906a7e087005be01d62cf89aa5f2f18
6
+ metadata.gz: 39d2cbb297b0e4cabc48543917b1c2c4ec7c5f1b12578f384cebd8ea1824a369a0561aac0ead6e72a8f4e28669e56c053d2dc59f242bf63d9bf526be7c7f49a6
7
+ data.tar.gz: d1910ba15650555ece8837356b2c580a22a214f7357918422eaf38d6bdfebb88b8e4d452250d51bfab7be8f3b2fb4e141f45c625988dd2afd09491b059536b72
data/README.md CHANGED
@@ -68,7 +68,22 @@ on your controller you could do something like this:
68
68
  class UsersController < ApplicationController
69
69
  def create
70
70
  user = User.create(user_params)
71
- user.avatar.attach(data: params[:avatar])
71
+ end
72
+
73
+ private
74
+
75
+ def user_params
76
+ params.require(:user).permit(avatar: [:data], :username, :email)
77
+ end
78
+ end
79
+ ```
80
+
81
+ Or you could also do:
82
+ ```ruby
83
+ class UsersController < ApplicationController
84
+ def create
85
+ user = User.create(user_params)
86
+ user.avatar.attach(params[:avatar])
72
87
  end
73
88
 
74
89
  private
@@ -114,6 +129,24 @@ class UsersController < ApplicationController
114
129
  end
115
130
  ```
116
131
 
132
+ Or, in case you want to have the avatar attached as soon as the user is created you can do:
133
+ ```ruby
134
+ class UsersController < ApplicationController
135
+ def create
136
+ user = User.create(user_params)
137
+ end
138
+
139
+ private
140
+
141
+ def user_params
142
+ params.require(:user).permit(:username, :email, avatar: [:data,
143
+ :filename,
144
+ :content_type,
145
+ :identify])
146
+ end
147
+ end
148
+ ```
149
+
117
150
  For more information on how to work with ActiveStorage, please check the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) mentioned above, all points in there apply to this gem as well.
118
151
 
119
152
  ## Contributing
@@ -132,3 +165,10 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
132
165
 
133
166
  Special thanks to the people who helped with guidance and ensuring code quality in this project:
134
167
  *Santiago Bartesaghi, Santiago Vidal and Matias Mansilla.*
168
+
169
+ ## Credits
170
+
171
+ Active Storage Base64 is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our
172
+ [contributors](https://github.com/rootstrap/active-storage-base64/contributors).
173
+
174
+ [<img src="https://s3-us-west-1.amazonaws.com/rootstrap.com/img/rs.png" width="100"/>](http://www.rootstrap.com)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'active_storage_base64'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
4
4
  s.summary = 'Base64 support for ActiveStorage'
5
5
  s.description = s.summary
6
6
 
@@ -14,16 +14,16 @@ Gem::Specification.new do |s|
14
14
  s.homepage = 'https://github.com/rootstrap/active-storage-base64'
15
15
  s.email = 'ricardo@rootstrap.com'
16
16
 
17
- s.required_ruby_version = ">= 2.2.2"
17
+ s.required_ruby_version = '>= 2.2.2'
18
18
 
19
19
  # Dependencies
20
- s.add_dependency 'rails', '~> 5.2.0', '<= 5.2.2'
20
+ s.add_dependency 'rails', '~> 5.2'
21
21
 
22
22
  # Development dependencies
23
- s.add_development_dependency 'rubocop', '~> 0.56.0'
23
+ s.add_development_dependency 'pry-rails', '~> 0.3.6'
24
24
  s.add_development_dependency 'reek', '~> 4.8.1'
25
25
  s.add_development_dependency 'rspec-rails', '~> 3.8.0'
26
- s.add_development_dependency 'sqlite3', '1.3.13'
27
- s.add_development_dependency 'pry-rails', '~> 0.3.6'
26
+ s.add_development_dependency 'rubocop', '~> 0.56.0'
28
27
  s.add_development_dependency 'simplecov'
28
+ s.add_development_dependency 'sqlite3', '1.3.13'
29
29
  end
@@ -4,7 +4,10 @@ module ActiveStorageSupport
4
4
  module_function
5
5
 
6
6
  def attachment_from_data(attachment)
7
- fill_attachment_data(attachment, attachment.delete(:data)) if attachment.is_a?(Hash)
7
+ if attachment.is_a?(Hash)
8
+ attachment = attachment.symbolize_keys
9
+ fill_attachment_data(attachment, attachment.delete(:data))
10
+ end
8
11
 
9
12
  attachment
10
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Cortio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-28 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,34 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
20
- - - "<="
21
- - !ruby/object:Gem::Version
22
- version: 5.2.2
19
+ version: '5.2'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 5.2.0
30
- - - "<="
31
- - !ruby/object:Gem::Version
32
- version: 5.2.2
26
+ version: '5.2'
33
27
  - !ruby/object:Gem::Dependency
34
- name: rubocop
28
+ name: pry-rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 0.56.0
33
+ version: 0.3.6
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 0.56.0
40
+ version: 0.3.6
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: reek
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -73,47 +67,47 @@ dependencies:
73
67
  - !ruby/object:Gem::Version
74
68
  version: 3.8.0
75
69
  - !ruby/object:Gem::Dependency
76
- name: sqlite3
70
+ name: rubocop
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - '='
73
+ - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: 1.3.13
75
+ version: 0.56.0
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
- - - '='
80
+ - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: 1.3.13
82
+ version: 0.56.0
89
83
  - !ruby/object:Gem::Dependency
90
- name: pry-rails
84
+ name: simplecov
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
87
+ - - ">="
94
88
  - !ruby/object:Gem::Version
95
- version: 0.3.6
89
+ version: '0'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
- - - "~>"
94
+ - - ">="
101
95
  - !ruby/object:Gem::Version
102
- version: 0.3.6
96
+ version: '0'
103
97
  - !ruby/object:Gem::Dependency
104
- name: simplecov
98
+ name: sqlite3
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - ">="
101
+ - - '='
108
102
  - !ruby/object:Gem::Version
109
- version: '0'
103
+ version: 1.3.13
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - ">="
108
+ - - '='
115
109
  - !ruby/object:Gem::Version
116
- version: '0'
110
+ version: 1.3.13
117
111
  description: Base64 support for ActiveStorage
118
112
  email: ricardo@rootstrap.com
119
113
  executables: []
@@ -158,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
152
  version: '0'
159
153
  requirements: []
160
154
  rubyforge_project:
161
- rubygems_version: 2.7.7
155
+ rubygems_version: 2.7.6
162
156
  signing_key:
163
157
  specification_version: 4
164
158
  summary: Base64 support for ActiveStorage