我正在尝试使用我的 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
Run Code Online (Sandbox Code Playgroud)
在显示 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>
Run Code Online (Sandbox Code Playgroud)
我只是想获取这张活动存储照片的网址。我尝试用谷歌搜索此错误,但没有看到任何包含此错误消息的内容。任何帮助将不胜感激!
activerecord ruby-on-rails uninitialized-constant rails-activestorage
我目前正在尝试运行 run.rb 文件,但我不断收到 sqlite3 的错误。当我输入 时bundle install,我收到此成功消息:
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using rake 12.3.2
Using concurrent-ruby 1.1.4
Using i18n 1.5.3
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.2
Using activemodel 5.2.2
Using arel 9.0.0
Using activerecord 5.2.2
Using bundler 2.0.1
Using coderay 1.1.2
Using equatable 0.5.0
Using method_source 0.9.2
Using mustermann 1.0.3
Using necromancer 0.4.0
Using tty-color 0.4.3
Using pastel 0.7.2
Using pry 0.12.2
Using rack 2.0.6
Using rack-protection 2.0.5
Using …Run Code Online (Sandbox Code Playgroud)