简体   繁体   English

使用Rails 5.2在活动存储上没有方法错误

[英]No method error on active storage with Rails 5.2

In a rails engine using RSpec for testing, I have to list my rails frameworks instead of using include "rails/all" so the mini-test unit isn't created. 在使用RSpec进行测试的Rails引擎中,我必须列出我的rails框架,而不是使用include“ rails / all”,这样就不会创建迷你测试单元。 I keep getting a no method error or active storage. 我不断收到无方法错误或活动存储。 Its a new feature of Rails 5.2 to enable storage on cloud sources, but I can't find a way to require that feature. 它是Rails 5.2的一项新功能,可以在云源上启用存储,但是我找不到要求该功能的方法。 I tried "activestorage" and activestorage/railties". I installed active storage. 我尝试了“ activestorage”和“ activestorage / railies”。我安装了活动存储。

# require 'rails/all'   # cannot use due to RSpec instead of mini-test
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"

It'd be great to see a stack trace of what your error looks like. 很高兴看到您的错误的堆栈跟踪。 However, maybe this will help. 但是,也许这会有所帮助。 For using Rails 5.2.0 with RSpec and ActiveStorage, this is what my config/application.rb looks like: 对于将Rails 5.2.0与RSpec和ActiveStorage一起使用,这是我的config/application.rb样子:

# config/application.rb

require 'rails'
# Pick the frameworks you want:
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'

If the above doesn't help, please update your question with the command you ran and the full stack trace of the errors you're getting. 如果上述方法无济于事,请使用您运行的命令以及所获取错误的完整堆栈跟踪记录来更新您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM