'method_missing':(NoMethodError)的未定义方法'active_storage'

时间:2018-09-15 22:19:59

标签: ruby-on-rails rails-activestorage

我目前生成了Ruby on Rails 5.2应用程序。当我运行rails active_storage:install时,它创建了一个20180915211415_create_active_storage_tables迁移。但是,尝试启动服务器时遇到以下错误。

/Users/stevenaguilar/.rvm/gems/ruby-2.2.2/gems/railties-5.2.1/lib/rails/railtie/configuration.rb:97:in `method_missing': undefined method `active_storage' for
#<Rails::Application::Configuration:0x007f80bbbf1c18> (NoMethodError)

这是我的gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|   repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")   "https://github.com/#{repo_name}.git" end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2'
# Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server gem 'puma', '~> 3.7'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5'

gem 'activestorage', '~> 5.2', '>= 5.2.1'
# Authentication gem 'devise'

gem 'bootsnap'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do   # Call 'byebug' anywhere in the code to stop execution and get a debugger console   gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]   # Adds support for Capybara system testing and selenium driver   gem 'capybara', '~> 2.13'   gem 'selenium-webdriver' end

group :development do   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.   gem 'web-console', '>=
3.3.0'   gem 'listen', '>= 3.0.5', '< 3.2'   # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring   gem 'spring'   gem 'spring-watcher-listen', '~> 2.0.0' end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

在application.rb文件中:

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module ArtsySpace
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
  end
end

我遵循以下article中的安装说明: 但是,这给我带来了问题,因此我决定删除该应用程序并从头开始。 rails _5.2.1_ new vuejs-ror-setup -M -C -S --skip-turbolinks --webpack=vue -d postgresql

以以下方式。不知道是什么原因导致此错误?

1 个答案:

答案 0 :(得分:7)

您需要使用其他框架加载Active Storage:

# config/application.rb
require "active_storage/engine"