生产中的Active_Storage(无法加载资源:500错误)

时间:2019-06-19 12:03:04

标签: ruby-on-rails

我正在使用active_storage存储一个模型(项目)的多张照片。 在检查器控制台中,我遇到500错误,无法加载资源。

我的Project。新表格

<%= f.input :images, as: :file, input_html: { multiple: true } %>"

我的控制器

class ProjectsController < ApplicationController
  skip_before_action :authenticate_user!, only: [:index, :show]
  before_action :set_project, only: [:show, :edit, :update, 
:destroy]

  def index
    @projects = Project.all
  end

  def new
    @project = Project.new
  end

  def create
    @project = Project.new(project_params)
    if @project.save
      redirect_to project_path(@project)
    else
      render :new
    end
  end

  def update

    if @project.update(project_params)
      redirect_to project_path(@project)
    else
      flash[:error] = 'Didn\'t save'
    end
  end

  def edit
  end

  def show
  end

  private

 def project_params
    projectParams = params.require(:project).permit(:title, 
:description, :remove_image, :objective, :technology, :project_type, 
:url, :programming_language, components:[], images:[])
  end

  def set_project
    @project = Project.find(params[:id])
  end
end

我的项目模型

class Project < ApplicationRecord
  has_many_attached :images

  attr_accessor :remove_image

  after_save :purge_images, if: :remove_image
  private def purge_images
    images.purge_later
  end

end

这是我的终端错误

Errno :: ENOENT(没有这样的文件或目录@ rb_file_s_mtime-/ app / storage / S7 / vk / S7vkBW2r7UitAHR33kSEqq3M):

2019-06-18T19:29:47.072176 + 00:00 app [web.1]:F,[2019-06-18T19:29:47.072105#4]致命-:[bf728315-012e-45f4-9d98 -47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / rack-2.0.7 / lib / rack / file.rb:63:in mtime' 2019-06-18T19:29:47.072178+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/rack-2.0.7/lib/rack/file.rb:63:in serving' 2019-06-18T19:29:47.072179 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / activestorage-5.2.2.1 / app /controllers/active_storage/disk_controller.rb:42:in serve_file' 2019-06-18T19:29:47.072180+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/activestorage-5.2.2.1/app/controllers/active_storage/disk_controller.rb:12:in显示' 2019-06-18T19:29:47.072181 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / actionpack-5.2.2.1 / lib /action_controller/metal/basic_implicit_render.rb:6:in send_action' 2019-06-18T19:29:47.072182+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/actionpack-5.2.2.1/lib/abstract_controller/base.rb:194:in process_action' 2019-06-18T19:29:47.072183 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / actionpack-5.2.2.1 / lib /action_controller/metal/rendering.rb:30:在process_action' 2019-06-18T19:29:47.072184+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/actionpack-5.2.2.1/lib/abstract_controller/callbacks.rb:42:in块中的process_action'中 2019-06-18T19:29:47.072185 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / activesupport-5.2.2.1 / lib /active_support/callbacks.rb:132:在run_callbacks' 2019-06-18T19:29:47.072186+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/actionpack-5.2.2.1/lib/abstract_controller/callbacks.rb:41:in process_action'中 2019-06-18T19:29:47.072187 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / actionpack-5.2.2.1 / lib /action_controller/metal/rescue.rb:22:在process_action' 2019-06-18T19:29:47.072188+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/actionpack-5.2.2.1/lib/action_controller/metal/instrumentation.rb:34:in中位于process_action'中 2019-06-18T19:29:47.072189 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / activesupport-5.2.2.1 / lib /active_support/notifications.rb:168:in block in instrument' 2019-06-18T19:29:47.072190+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/notifications/instrumenter.rb:23:in仪器' 2019-06-18T19:29:47.072191 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / activesupport-5.2.2.1 / lib /active_support/notifications.rb:168:in instrument' 2019-06-18T19:29:47.072192+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/actionpack-5.2.2.1/lib/action_controller/metal/instrumentation.rb:32:in process_action' 2019-06-18T19:29:47.072193 + 00:00 app [web.1]:[bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor / bundle / ruby​​ / 2.4.0 / gems / actionpack-5.2.2.1 / lib /action_controller/metal/params_wrapper.rb:256:in process_action' 2019-06-18T19:29:47.072194+00:00 app[web.1]: [bf728315-012e-45f4-9d98-47ddb3ce2ffa] vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.2.1/lib/active_record/railties/controller_runtime.rb:24:in process_action'  ▸日志事件源失败,失败:401未经授权

0 个答案:

没有答案