lundi 5 octobre 2020

I am getting an ActiveJob::DeserializationError when trying to attach photo while seeding

I am trying to learn how to use active storage and AWS. I am attempting to give Users the option of having a picture and I managed to make it work within my app, but am stuck when trying to give users in my seed file photos.

Right now some problematic code in my seeds file is:

User.destroy_all

user = User.create!(
    id: "1",
    email: "admin",
    password: "admin1"
)

file = File.open('app/assets/images/robot-avatar.png')
user.photo.attach(io: file, filename: 'robot-avatar.png')

When I run rails db:seed, I'm receiving an error which states:

ActiveJob::DeserializationError: Error while trying to deserialize arguments: Couldn't find ActiveStorage::Blob with 'id'=17

Im still pretty new to coding in general, and extremely new when it comes to Active Storage/AWS, so any help would be appreciated. Thanks

Aucun commentaire:

Enregistrer un commentaire