blob: 7fc1e43e07e922a6cfb0ff55830861ec518619b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# Active Vault
...
## Example
```ruby
class User < ApplicationRecord
has_one_attached :avatar
end
user.avatar.attach io: File.open("~/face.jpg"), filename: "avatar.jpg", content_type: "image/jpg"
user.avatar.exist? # => true
user.avatar.purge
user.avatar.exist? # => false
user.image.url(expires_in: 5.minutes) # => /rails/blobs/<encoded-key>
class AvatarsController < ApplicationController
def update
Current.user.avatar.attach(params.require(:avatar))
redirect_to Current.user
end
end
```
## License
Active Vault is released under the [MIT License](https://opensource.org/licenses/MIT).
|