How to Migrate from Paperclip to Rails ActiveStorage Discussion
instance.send(attachment).path
file_path = k.send(value).path.split('/system', 2).second
ArgumentError: wrong number of arguments (given 1, expected 2..3)
/Users/nicknoble/products/Lnky/db/migrate/20180531013954_convert_to_active_storage.rb:14:inprepare'
up'
/Users/nicknoble/products/Lnky/db/migrate/20180531013954_convert_to_active_storage.rb:14:in
I fixed this by changing to:
active_storage_blob_statement = ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
INSERT INTO active_storage_blobs (
`key`, filename, content_type, metadata, byte_size, checksum, created_at
) VALUES (?, ?, ?, '{}', ?, ?, ?)
SQL
active_storage_attachment_statement = ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
INSERT INTO active_storage_attachments (
name, record_type, record_id, blob_id, created_at
) VALUES (?, ?, ?, #{get_blob_id}, ?)
SQL
ArgumentError: You tried to define an enum named "industry" on the model "Company", but this will generate a instance method "horeca?", which is already defined by another enum.
No (offical) way to use validations (https://github.com/thoughtbot/paperclip#validations) for Active Storage yet. Mayor bummer …
Instead of building the URL in the def key
method, can't I use the same thing I used in checksum
?
url = attachment.url
I'm attempting to modify this migration to transition from Shrine to Active Storage.
get_blob_id = LASTVAL() was returning the id from the attachments table, NOT the blob_id. I had to change it to get_blob_id = "(SELECT max(id) from active_storage_blobs)". Any thoughts on this?
Quick question before starting this process. How can you approach this for multi tenant app with apartment gem? Has you use different DBs for the tables. Thank in advance.