【问题标题】:Couldn't get active storage to install/work in rails 5.2.1无法获得活动存储以在 rails 5.2.1 中安装/工作
【发布时间】:2018-11-12 09:14:42
【问题描述】:

我试过这个rails active_storage:install gives error,但我仍然遇到同样的错误

Don't know how to build task 'active_storage:install'

导轨 5.2.1 红宝石 2.5.1

也无法启动服务器。

/usr/local/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/railtie/configuration.rb:97:in `method_missing': undefined method `active_storage' for #<Rails::Application::Configuration:0x00007fc9493b7738> (NoMethodError)

如果config.active_storage.service = :local 被评论,我可以让服务器运行。

对不起,如果我犯了任何错误,第一次在这里提问,新手向 RoR。谢谢!


更新: config/application.rb:

require_relative 'boot'
require 'rails/all'
Bundler.require(*Rails.groups)
module Blogclass Application < Rails::Application
config.load_defaults 5.2
end
end

Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.1'

gem 'rails', '~> 5.2.0'
gem 'sqlite3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  gem 'capybara', '>= 2.15', '< 4.0'
  gem 'selenium-webdriver'
  gem 'chromedriver-helper'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

  • 你能分享你的config/application.rb和Gemfile吗?

标签: ruby-on-rails


【解决方案1】:

在config/application.rb 中的rails/all 下添加require "active_storage/engine"

require_relative 'boot'
require 'rails/all'
require "active_storage/engine"
Bundler.require(*Rails.groups)
module Blogclass Application < Rails::Application
config.load_defaults 5.2
end
end

【讨论】:

  • 谢谢@Auriga 现在我收到from /usr/local/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in block in require' /usr/local/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require': cannot load such file -- marcel
【解决方案2】:

尝试添加

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

更多详情请关注link

application.rb 文件看起来像:

# application.rb 
require_relative 'boot'
require "active_storage/engine"

require "rails"
# Pick the frameworks you want:
require "active_storage/engine"
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

【讨论】:

  • 谢谢,但它不起作用。同样的错误。我想知道,为什么我需要添加 activestorage gem,它不是捆绑到 rails 5.2 中了吗?
  • 查看 GitHub 存储库并尝试按照安装步骤进行操作。 github.com/rails/activestorage/tree/archive#installation
  • 对不起,我不明白。 1. 我在使用 rails 5.2 的全新应用程序,为什么我需要将此 gem 添加到 Gemfile 中? 2. gem "activestorage", git: "https://github.com/rails/activestorage.git" 这不起作用,因为 repo 已存档。 3. 我尝试这个而不是github.com/rails/rails/tree/master/activestorage,但当我做rails active_storage:install 时,我仍然得到LoadError: cannot load such file -- marcel。感谢您的帮助
  • @kailoon 1) 如果您使用的是 5.2 版本,则不需要将 gem 添加到 gemfile 中 2) 更正 repo 已存档,因此请使用 github.com/rails/rails/tree/master/activestorage
  • 尝试更新您的 bootsnap gem bundle update bootsnap 关注链接以供参考 github.com/Shopify/bootsnap/issues/73 或 stackoverflow.com/questions/51493625/…
猜你喜欢
  • 2016-05-13
  • 2019-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-07
  • 1970-01-01
  • 1970-01-01
  • 2019-05-17
相关资源
最近更新 更多