简体   繁体   中英

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. 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. I tried "activestorage" and activestorage/railties". I installed active storage.

# 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:

# 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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