使用 capistrano 部署时设计 gem 错误
Devise gem error while deploying with capistrano
我正在尝试使用 capistrano 在 Rails 应用程序上部署我的 Ruby,但是在 运行:
之后
cap production deploy:initial
部署失败并显示下一个错误:
rake aborted!
01 NoMethodError: undefined method `devise' for Client (call 'Client.connection' to establish a connection):Class
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
01 /home/deploy/apps/tuti/releases/20190611034848/app/models/client.rb:2:in `<class:Client>'
01 /home/deploy/apps/tuti/releases/20190611034848/app/models/client.rb:1:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5
01 .0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `load_interlock'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:356:in `require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:510:in `load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:195:in `const_missing'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `const_get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `block in constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `inject'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:582:in `get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:613:in `constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:320:in `get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:83:in `to'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:78:in `modules'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:95:in `routes'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:162:in `default_used_route'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:72:in `initialize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:350:in `new'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:350:in `add_mapping'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:243:in `block in devise_for'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:242:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:242:in `devise_for'
01
01 /home/deploy/apps/tuti/releases/20190611034848/config/routes.rb:2:in `block in <main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:414:in `draw'
01 /home/deploy/apps/tuti/releases/20190611034848/config/routes.rb:1:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `block in load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `load_paths'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:20:in `reload!'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:30:in `block in updater'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/file_update_checker.rb:83:in `execute'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:10:in `execute'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
01 /home/deploy/apps/tuti/releases/20190611034848/config/environment.rb:5:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'
01
01 /usr/local/rvm/gems/ruby-2.5.1/bin/bundle:23:in `<main>'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
01 Tasks: TOP => environment
01 (See full trace by running task with --trace)
#<Thread:0x00007ff438868790@/Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing on host XXX.XX.XX.XXX: rake exit status: 1 (SSHKit::Runner::ExecuteError)
这似乎是 Devise
gem 的一个错误,但我花了几个小时试图修复它,但我 运行 没主意了。
rails 应用程序在本地运行没有问题。
这是我的Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
install_plugin Capistrano::Puma
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
这是我的 deploy.rb
:
# Change these
server 'XXX.XX.XX.XXX', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, 'git@gitlab.com:warelan/e-commerce/tuti.git'
set :application, 'tuti'
set :user, 'deploy'
set :use_sudo, true
set :puma_threads, [4, 16]
set :puma_workers, 0
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
# set :linked_files, %w{config/database.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
您好,您可以 运行 您的 rails 应用程序在本地使用生产/舞台环境吗?
rails s RAILS_ENV=production
rails server -e production
检查一切正常
回答我的问题,希望它对将来的人有用。问题是显然模型需要从 Device::Models
扩展,我在 Devise 文档中没有找到任何内容,但是在将 extend Devise::Models
添加到我的 Client
模型后,错误不再显示。
class Client < ActiveRecord::Base
extend Devise::Models
# All my methods here
end
如果有人知道为什么会发生这种情况,如果您能评论原因就太好了。
我正在尝试使用 capistrano 在 Rails 应用程序上部署我的 Ruby,但是在 运行:
之后cap production deploy:initial
部署失败并显示下一个错误:
rake aborted!
01 NoMethodError: undefined method `devise' for Client (call 'Client.connection' to establish a connection):Class
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
01 /home/deploy/apps/tuti/releases/20190611034848/app/models/client.rb:2:in `<class:Client>'
01 /home/deploy/apps/tuti/releases/20190611034848/app/models/client.rb:1:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5
01 .0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `load_interlock'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:356:in `require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:510:in `load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:195:in `const_missing'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `const_get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283:in `block in constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `inject'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:281:in `constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:582:in `get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:613:in `constantize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:320:in `get'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:83:in `to'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:78:in `modules'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:95:in `routes'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:162:in `default_used_route'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/mapping.rb:72:in `initialize'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:350:in `new'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise.rb:350:in `add_mapping'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:243:in `block in devise_for'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:242:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/devise-4.6.2/lib/devise/rails/routes.rb:242:in `devise_for'
01
01 /home/deploy/apps/tuti/releases/20190611034848/config/routes.rb:2:in `block in <main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/actionpack-5.2.3/lib/action_dispatch/routing/route_set.rb:414:in `draw'
01 /home/deploy/apps/tuti/releases/20190611034848/config/routes.rb:1:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `block in load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `each'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:41:in `load_paths'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:20:in `reload!'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:30:in `block in updater'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/file_update_checker.rb:83:in `execute'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/routes_reloader.rb:10:in `execute'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
01 /home/deploy/apps/tuti/releases/20190611034848/config/environment.rb:5:in `<main>'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
01
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
01 /home/deploy/apps/tuti/shared/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'
01
01 /usr/local/rvm/gems/ruby-2.5.1/bin/bundle:23:in `<main>'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval'
01 /usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
01 Tasks: TOP => environment
01 (See full trace by running task with --trace)
#<Thread:0x00007ff438868790@/Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/danielavila/.rvm/gems/ruby-2.5.1/gems/sshkit-1.15.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing on host XXX.XX.XX.XXX: rake exit status: 1 (SSHKit::Runner::ExecuteError)
这似乎是 Devise
gem 的一个错误,但我花了几个小时试图修复它,但我 运行 没主意了。
rails 应用程序在本地运行没有问题。
这是我的Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
install_plugin Capistrano::Puma
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
这是我的 deploy.rb
:
# Change these
server 'XXX.XX.XX.XXX', port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, 'git@gitlab.com:warelan/e-commerce/tuti.git'
set :application, 'tuti'
set :user, 'deploy'
set :use_sudo, true
set :puma_threads, [4, 16]
set :puma_workers, 0
# Don't change these unless you know what you're doing
set :pty, true
set :use_sudo, false
set :stage, :production
set :deploy_via, :remote_cache
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log, "#{release_path}/log/puma.access.log"
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord
## Defaults:
# set :scm, :git
# set :branch, :master
# set :format, :pretty
# set :log_level, :debug
# set :keep_releases, 5
## Linked Files & Directories (Default None):
# set :linked_files, %w{config/database.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :puma do
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
end
end
before :start, :make_dirs
end
namespace :deploy do
desc "Make sure local git is in sync with remote."
task :check_revision do
on roles(:app) do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
desc 'Initial Deploy'
task :initial do
on roles(:app) do
before 'deploy:restart', 'puma:start'
invoke 'deploy'
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
invoke 'puma:restart'
end
end
before :starting, :check_revision
after :finishing, :compile_assets
after :finishing, :cleanup
after :finishing, :restart
end
# ps aux | grep puma # Get puma pid
# kill -s SIGUSR2 pid # Restart puma
# kill -s SIGTERM pid # Stop puma
您好,您可以 运行 您的 rails 应用程序在本地使用生产/舞台环境吗?
rails s RAILS_ENV=production
rails server -e production
检查一切正常
回答我的问题,希望它对将来的人有用。问题是显然模型需要从 Device::Models
扩展,我在 Devise 文档中没有找到任何内容,但是在将 extend Devise::Models
添加到我的 Client
模型后,错误不再显示。
class Client < ActiveRecord::Base
extend Devise::Models
# All my methods here
end
如果有人知道为什么会发生这种情况,如果您能评论原因就太好了。