运行Rails active_storage:install时发生LoadError

时间:2019-09-07 07:56:52

标签: ruby-on-rails rails-activestorage

我是不熟悉ruby的人,正在尝试构建一个基本的待办事项列表应用程序。我的红宝石版本是2.5.5,Rails版本是5.1.7。我正在尝试在应用程序中设置active_storage,但是无法运行命令rails active_storage:install。我在Windows 8.1 x64系统上。

这是错误跟踪:

C:\Users\Sreekar\Documents\GitHub\todo-app>rails active_storage:install --trace
rails aborted!
LoadError: cannot load such file -- active_storage/engine
C:/Users/Sreekar/Documents/GitHub/todo-app/config/application.rb:4:in `require'
C:/Users/Sreekar/Documents/GitHub/todo-app/config/application.rb:4:in `<top (required)>'
C:/Users/Sreekar/Documents/GitHub/todo-app/Rakefile:4:in `require_relative'
C:/Users/Sreekar/Documents/GitHub/todo-app/Rakefile:4:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.1.7/lib/rails/commands/rake/rake_command.rb:18:in `perform'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.1.7/lib/rails/command.rb:46:in `invoke'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

我已经尝试在我的require active_storage/engine文件中包含config/application.rb,但是它不起作用。

这些是我的application.rb文件的内容:

require_relative 'boot'
require 'rails/all'
require 'active_storage/engine'

Bundler.require(*Rails.groups)

module TodoApp
class Application < Rails::Application
config.load_defaults 5.1

我需要在模式active_storage_blobs中创建两个表:active_storage_attachmentsrails db:migrate。 感谢您提供有关如何使其正常工作的帮助。谢谢!

1 个答案:

答案 0 :(得分:1)

支持活动存储,默认情况下它们是Rails版本> = 5.2中的版本。您的Rails版本是5.1.7

因此,您应该考虑将应用程序升级到Rails 5.2See this link)以使用活动存储。