Ruby on Rails Tuesday, October 23, 2018

I'm migrating from Shrine to Active Storage. It's very similar to migrating from paperclip. Active storage works, but the migration is not moving my existing data over properly. 

Background: 
1. Modified the migration here: https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md to use Shrine data. 
2. Checked in my local database that the records are getting properly created. 

siftlocal_co_development=# TABLE active_storage_attachments;

  id  |  name  | record_type | record_id | blob_id |     created_at      

------+--------+-------------+-----------+---------+---------------------

 7848 | avatar | Profile     |         1 |    7889 | 2018-03-21 03:33:51

(1 row)


siftlocal_co_development=# TABLE active_storage_blobs;

  id  |                             key                              |   filename    | content_type | metadata | byte_size |         checksum         |     created_at      

------+--------------------------------------------------------------+---------------+--------------+----------+-----------+--------------------------+---------------------

 7889 | users/1/avatar/original/64024d6a2d2a3b816522a717d468123c.jpg | photobill.jpg | image/jpeg   | {}       |     54177 | NCc6WyXlpm3fJHI8utmAmQ== | 2018-03-21 03:33:51

(1 row)


3. Made all the code changes to use active storage. 
4. I can persist and upload new images, but the old images are not transferred over. 

It I view my images before active storage they point to /mybucket/aws/path/someotherstuff. If I view the image source after moving to active storage they point to /localhost3000/rails/active_storage...and they're not there. 

In the GoRails video on this he says Active Storage will go download the files based on the key. So, the key in my table is the path and the checksum is the complete url with the hash. 

I also updated my config to use amazon  config.active_storage.service = :amazon

Not sure why my files aren't transferring.  

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e1900af1-e2ac-498a-bae8-c6dc09bcf262%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment