mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #44439 from ghousemohamed/patch-6
Return the blob/blobs when #attach is able to save the record
This commit is contained in:
commit
fb88db58d7
3 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
* Saving attachment(s) to a record returns the blob/blobs object
|
||||||
|
|
||||||
|
Previously, saving attachments did not return the blob/blobs that
|
||||||
|
were attached. Now, saving attachments to a record with `#attach`
|
||||||
|
method returns the blob or array of blobs that were attached to
|
||||||
|
the record. If it fails to save the attachment(s), then it returns
|
||||||
|
`false`.
|
||||||
|
|
||||||
|
*Ghouse Mohamed*
|
||||||
|
|
||||||
* Don't stream responses in redirect mode
|
* Don't stream responses in redirect mode
|
||||||
|
|
||||||
Previously, both redirect mode and proxy mode streamed their
|
Previously, both redirect mode and proxy mode streamed their
|
||||||
|
|
|
@ -49,7 +49,11 @@ module ActiveStorage
|
||||||
def attach(*attachables)
|
def attach(*attachables)
|
||||||
if record.persisted? && !record.changed?
|
if record.persisted? && !record.changed?
|
||||||
record.public_send("#{name}=", blobs + attachables.flatten)
|
record.public_send("#{name}=", blobs + attachables.flatten)
|
||||||
record.save
|
if record.save
|
||||||
|
record.public_send("#{name}")
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
record.public_send("#{name}=", (change&.attachables || blobs) + attachables.flatten)
|
record.public_send("#{name}=", (change&.attachables || blobs) + attachables.flatten)
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,11 @@ module ActiveStorage
|
||||||
def attach(attachable)
|
def attach(attachable)
|
||||||
if record.persisted? && !record.changed?
|
if record.persisted? && !record.changed?
|
||||||
record.public_send("#{name}=", attachable)
|
record.public_send("#{name}=", attachable)
|
||||||
record.save
|
if record.save
|
||||||
|
record.public_send("#{name}")
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
record.public_send("#{name}=", attachable)
|
record.public_send("#{name}=", attachable)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue