根据Rails(edge6.0)指南,我们可以通过分别调用以下语句来对系统测试和集成测试中使用的ActiveStorage进行维护工作
# System Test
FileUtils.rm_rf("#{Rails.root}/storage_test")
# Integration Test
FileUtils.rm_rf(Rails.root.join('tmp', 'storage'))
Run Code Online (Sandbox Code Playgroud)
我想知道 -
是否有任何 Rails 内置函数或 rake 命令或 gem 可以执行以下操作?
ActiveStorage::Blob不再与任何ActiveStorage::Attachment记录关联的记录)ActiveStorage::Blob记录关联的文件)我没有看到任何相关的 rake 任务rails --tasks。
目前,我正在使用
# remove blob not associated with any attachment
ActiveStorage::Blob.where.not(id: ActiveStorage::Attachment.select(:blob_id)).find_each do |blob|
blob.purge # or purge_later
end
Run Code Online (Sandbox Code Playgroud)
这个脚本用于清理孤立文件(通过rails console)
# run these ruby statement in project rails console
# to remove the orphan file
include …Run Code Online (Sandbox Code Playgroud) 赛普拉斯可以录制测试视频,我想知道是否有任何现有方法可以直观地包含鼠标单击操作?
我正在调查