aboutsummaryrefslogblamecommitdiffstats
path: root/README.md
blob: 7fc1e43e07e922a6cfb0ff55830861ec518619b0 (plain) (tree)
1
2
3
4
5
6
7
8
9
              




          
       

                              

   

                                                                                                 
 

                             
 
                                                                     
 
                                               
            

                                                       

     
   


          
                                                                                      
# 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).