active_shrine 0.3.0 → 0.3.1

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: 698b07ac6ab5b98eecfeae48419c2c5203cf6ae8f2c3e1c924aa0c2de6ee3513
4
- data.tar.gz: 56439876a6a623a4e3d27f0b9080f00197b444430043d74ddecf6ccb3c0f9542
3
+ metadata.gz: 756c7f37f8450e532d53547e256301bdb3368e6ce8b27248566a051d7a0ab880
4
+ data.tar.gz: 8d089b85b9a0d4ff6b80b5088f45a35daa2fc3218897a6b02938e507210f10e2
5
5
  SHA512:
6
- metadata.gz: 629bf6b87acb29d9f4468d2869b8d20dd736e28817ca129061661b78f2245d646faae0dd81fb6d52404a9901d9beae9a25ce5a76c88ac013d38f4ada48f6b0e0
7
- data.tar.gz: c171501c31fe29b67b8240aa89dad180bbdc10fe6e11d7d142ab4c9f9f7c1a05945d6fe633404bacb6e23148299a5812793b4bd27b1594a0d4f580acf99518a3
6
+ metadata.gz: 3b9bfe585f6ded80b0dfa17626eec1a74c6d2fc82e67b519dd0363df5baa6199681e814ca80a9240c18c9b2229aa775efecacf35bb86ba773887f049f8dd68ec
7
+ data.tar.gz: 351afd5f4ab728e5313e3d57a4691b319ad5ecae8c21cc36b98cc2ccd0806ac13a00fc90545bc98617452bd96a69e183e991ae40b72db2ef8cb27ea62e080cae
data/README.md CHANGED
@@ -121,7 +121,7 @@ After checking out the repo:
121
121
  4. Push to the branch (`git push origin my-new-feature`)
122
122
  5. Create new Pull Request
123
123
 
124
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_shrine.
124
+ Bug reports and pull requests are welcome on GitHub at https://github.com/radioactive-labs/active_shrine.
125
125
 
126
126
  ## License
127
127
 
@@ -129,4 +129,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
129
129
 
130
130
  ## Code of Conduct
131
131
 
132
- Everyone interacting in the ActiveShrine project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_shrine/blob/main/CODE_OF_CONDUCT.md).
132
+ Everyone interacting in the ActiveShrine project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_shrine/blob/main/CODE_OF_CONDUCT.md).
@@ -36,8 +36,8 @@ module ActiveShrine
36
36
 
37
37
  before_save :maybe_store_record
38
38
 
39
- def url
40
- file_url
39
+ def url(derivative=nil)
40
+ file_url(derivative) || file_url
41
41
  end
42
42
 
43
43
  def content_type
@@ -137,7 +137,12 @@ module ActiveShrine
137
137
 
138
138
  scope :"with_attached_#{name}", -> { includes(:"#{name}_attachment") }
139
139
 
140
- after_save { shrine_attachment_changes[name.to_s]&.save }
140
+ after_save do
141
+ shrine_attachment_changes[name.to_s]&.save
142
+ rescue => e
143
+ errors.add(name, :invalid, message: "failed to save. Please make sure it is a valid file.")
144
+ raise ActiveRecord::RecordInvalid.new(self)
145
+ end
141
146
 
142
147
  after_commit(on: %i[create update]) { shrine_attachment_changes.delete(name.to_s) }
143
148
 
@@ -232,7 +237,12 @@ module ActiveShrine
232
237
 
233
238
  scope :"with_attached_#{name}", -> { includes(:"#{name}_attachments") }
234
239
 
235
- after_save { shrine_attachment_changes[name.to_s]&.save }
240
+ after_save do
241
+ shrine_attachment_changes[name.to_s]&.save
242
+ rescue => e
243
+ errors.add(name, :invalid, message: "failed to save. Please make sure it is a valid file.")
244
+ raise ActiveRecord::RecordInvalid.new(self)
245
+ end
236
246
 
237
247
  after_commit(on: %i[create update]) { shrine_attachment_changes.delete(name.to_s) }
238
248
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveShrine
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radioactive Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-02 00:00:00.000000000 Z
11
+ date: 2025-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties