# ActiveStorage attach method

**URL:** <https://discuss.rubyonrails.org/t/activestorage-attach-method/76041>\
**Category:** rubyonrails-talk\
**Created:** [August 10, 2020, 3:42pm UTC](https://discuss.rubyonrails.org/t/activestorage-attach-method/76041 "2020-08-10T15:42:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterbaker](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/peterbaker/32/2301_2.png) [@peterbaker](https://discuss.rubyonrails.org/u/peterbaker)\
**Post date:** [August 10, 2020, 3:42pm UTC](https://discuss.rubyonrails.org/t/activestorage-attach-method/76041/1 "2020-08-10T15:42:07Z")

</div>

If you create a new ActiveStorage model and then send the `:attach` method to it, will there be any blobs left in the database when the transaction is rolled back? In a scenario like this:

```ruby
class User < ApplicationRecord
  has_one_attached :avatar
  validates :name, presence: true
end

class UsersController < ApplicationController
  def create
    user = User.new(name: '', handle: 'peterbaker')
    user.avatar.attach(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/jpg") 
    user.save!
  end
end

```
