Rails 5.2 не загружается в производственной среде - PullRequest
0 голосов
/ 28 декабря 2018

Я пытаюсь запустить мое новое приложение в работе, но я получаю странную ошибку.

$ rails server --environment=production
=> Booting Puma
=> Rails 5.2.2 application starting in production 
=> Run `rails server -h` for more startup options
Exiting
/Users/user/.rvm/gems/ruby-2.4.1/gems/activerecord-5.2.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for #<Class:0x007fc50e4e3e70> (NoMethodError)
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.2/app/models/active_storage/blob/representable.rb:7:in `block in <module:Representable>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/concern.rb:122:in `class_eval'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/concern.rb:122:in `append_features'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.2/app/models/active_storage/blob.rb:23:in `include'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.2/app/models/active_storage/blob.rb:23:in `<class:Blob>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.2/app/models/active_storage/blob.rb:16:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:378:in `block in require_or_load'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:13:in `loading'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `load_interlock'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:356:in `require_or_load'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:46:in `block in require_or_load'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:45:in `require_or_load'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:334:in `depend_on'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `depend_on'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:246:in `require_dependency'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:477:in `each'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:477:in `block in eager_load!'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:475:in `each'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:475:in `eager_load!'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/engine.rb:356:in `eager_load!'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `each'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
    from /Users/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
    from /Users/user/Projects/My App/app-name/config/environment.rb:5:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
    from config.ru:3:in `block in <main>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
    from config.ru:in `new'
    from config.ru:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/builder.rb:40:in `parse_file'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/server.rb:319:in `build_app_and_options_from_config'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/server.rb:219:in `app'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27:in `app'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/server.rb:354:in `wrapped_app'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/rack-2.0.6/lib/rack/server.rb:283:in `start'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:53:in `start'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `tap'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `perform'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/command/base.rb:65:in `perform'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/command.rb:46:in `invoke'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
    from /Users/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
    from bin/rails:4:in `<main>'

Обычное приближение не найдено и полезные ответы.Кто-нибудь имеет представление о том, как я могу заставить это работать в производственной среде?

Интересно, что трассировка стека указывает на строку 5 environment.rb, который не изменился по умолчанию, но имеет этоline.

Rails.application.initialize!

Когда я комментирую это, сервер наконец запускается, но происходит сбой, как только я загружаю любую страницу (очевидно).

Любые указатели будут очень благодарны!Я не использую какие-либо методы has_one_attached в своем приложении, поэтому я не уверен, где искать дальше!

Ответы [ 2 ]

0 голосов
/ 29 декабря 2018

дракончик.Знаешь что?Похоже, это было из-за моей неправильной конфигурации в разделе production: файла database.yml.

0 голосов
/ 29 декабря 2018

Установите активное хранилище, выполнив следующие команды:

 rails active_storage:install
 db:migrate

Добавьте новый атрибут в вашей модели как:

has_one_attached :image

Также вам потребуется «active_storage»в вашем файле application.rb

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...