我正在尝试使用我的 Rails 数据库并不断遇到此错误。该数据库之前一直在工作,直到 5 天前它停止并且我开始看到此错误时才出现活动存储问题:
*** NameError Exception: uninitialized constant ActiveStorage::Attachment::ActiveStorage::Blob
我有一个发生错误的 .jbuilder 文件,
json.array! @campaigns do |campaign|
byebug
json.extract! campaign, :id, :title, :description, :goal, :campaign_end, :user_id, :current_amount, :ends, :percent_complete, :amount_left_to_fund, :owner, :successful
json.photoUrl url_for(campaign.photo)
end
它说 url_for(campaign.photo) 我得到错误。但是,只需键入 campaign.photo 即可显示 ActiveStorage 实例及其附加的活动:
#<ActiveStorage::Attached::One:0x00007febc64f91b0 @name="photo", @record=#<Campaign id: 7, title: "Surgery", description: "Lorem ipsum dolor sit amet, consectetur adipiscing...", goal: 5000, user_id: 8, campaign_end: "2019-05-31 16:00:00", created_at: "2019-05-01 14:20:14", updated_at: "2019-05-01 14:20:14", successful: false>, @dependent=:purge_later>
我只是想获取这张活动存储照片的 url。我尝试用谷歌搜索这个错误,但没有看到任何与此错误消息有关的内容。任何帮助将不胜感激!