ruby-on-rails - Rails 5.2.3 创建文件时活动存储出现 Blob 错误
问题描述
我正在使用 rails 5.2.3,并且正在尝试将 ActiveStorage 用于新的脚手架议程。我已经按照这个教程
我想将文件本地保存在文件系统上。
当我想通过 web 表单创建一个新对象时,我收到以下错误:
无法自动加载常量 ActiveStorage::Blob::Analyzable,预期 /home/vagrant/.rvm/gems/ruby-2.6.2/gems/activestorage-5.2.3/app/models/active_storage/blob/analyzable.rb 来定义它
从邮件日志:
[错误] blogs create (NoMethodError) "Cannot load
Rails.config.active_storage.service
:\nundefined method `fetch' for n
当我刷新页面时,我得到:
nil:NilClass 的未定义方法“fetch”
我的定义
型号:
has_one_attached :image
控制器:
def create
@blog = Blog.new(blog_params)
.
.
end
def blog_params
params.require(:blog).permit(:name, :audit_comment, :image)
end
意见:
= simple_form_for(blog) do |f|
= f.error_notification
.form-inputs
= f.input :name, label: 'Name'
= f.file_field :image
= f.input :audit_comment
.form-actions
= f.button :submit
在development.rb中:
config.active_storage.service = :local
我错过了什么?我已经按照此设置的建议rails active_storage:install
运行和迁移
当我使用全新的 Rails 应用程序时,它运行良好。
解决方案
推荐阅读
- sql - 根据输入日期获取日期范围(日和月)内的所有数据
- r - 在不使用 R 中的内置函数的情况下生成几何变量
- json - 如何使用 NimYAML 将 JsonNode 转储到 yaml 文件?
- xamarin.forms - Xamarin Forms:删除网格元素之间的间隙
- android - 我正在创建 react-native 应用程序,我的 api 是在节点中开发的,我正在尝试从 API 获取数据,但我做不到
- keras - GridSearchCV - 无需改装的最佳模型
- vb.net - 具有下推效果的按钮的代码?VB网
- ios - 父对话框中 KeyboardAvoidingView 的反应原生内容
- javascript - 无法在专用网络上获取 /peerjs/id
- protocol-buffers - Protobuf 组和消息