代码之家  ›  专栏  ›  技术社区  ›  Steven Aguilar

'method\u missing'(NoMethodError)的未定义方法'active\u storage'

  •  2
  • Steven Aguilar  · 技术社区  · 7 年前

    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)
    

    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]
    

    在应用程序.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 回复  |  直到 7 年前
        1
  •  14
  •   George Claghorn    7 年前

    # config/application.rb
    require "active_storage/engine"
    
    推荐文章