`method_missing ': неопределенный метод` devise' для модели (вызов 'Model.connection' для установления sh соединения): Class (NoMethodError) - PullRequest
0 голосов
/ 26 мая 2020

При попытке установить генератор на devise я получил ошибку «метод отсутствует». Я должен был выполнить несколько шагов для успешной установки devise, но все, что я получил, это длинный блок сообщений об ошибках:

Neeko-MacBook-Pro:cabinet neekocurious$ rails generate devise:install
/Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `devise' for Model (call 'Model.connection' to establish a connection):Class (NoMethodError)
        from /Users/neekocurious/Documents/Software Development Projects/Ruby Projects/cabinet/app/models/model.rb:4:in `<class:Model>'
        from /Users/neekocurious/Documents/Software Development Projects/Ruby Projects/cabinet/app/models/model.rb:1:in `<top (required)>'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:16:in `require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/inflector/methods.rb:282:in `const_get'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/inflector/methods.rb:282:in `block in constantize'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/inflector/methods.rb:280:in `each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/inflector/methods.rb:280:in `inject'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/inflector/methods.rb:280:in `constantize'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise.rb:320:in `get'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/mapping.rb:83:in `to'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/mapping.rb:78:in `modules'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/mapping.rb:95:in `routes'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/mapping.rb:162:in `default_used_route'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/mapping.rb:72:in `initialize'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise.rb:350:in `new'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise.rb:350:in `add_mapping'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/rails/routes.rb:243:in `block in devise_for'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/rails/routes.rb:242:in `each'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/devise-4.7.1/lib/devise/rails/routes.rb:242:in `devise_for'
        from /Users/neekocurious/Documents/Software Development Projects/Ruby Projects/cabinet/config/routes.rb:2:in `block in <top (required)>'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/actionpack-6.0.2.2/lib/action_dispatch/routing/route_set.rb:429:in `instance_exec'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/actionpack-6.0.2.2/lib/action_dispatch/routing/route_set.rb:429:in `eval_block'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/actionpack-6.0.2.2/lib/action_dispatch/routing/route_set.rb:411:in `draw'
        from /Users/neekocurious/Documents/Software Development Projects/Ruby Projects/cabinet/config/routes.rb:1:in `<top (required)>'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:41:in `each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:41:in `load_paths'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:20:in `reload!'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:30:in `block in updater'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/file_update_checker.rb:83:in `execute'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/routes_reloader.rb:10:in `execute'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application/finisher.rb:184:in `block in <module:Finisher>'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `run'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `call'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:363:in `initialize!'
        from /Users/neekocurious/Documents/Software Development Projects/Ruby Projects/cabinet/config/environment.rb:5:in `<top (required)>'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application.rb:106:in `preload'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
        from /Users/neekocurious/.rvm/gems/ruby-2.5.7/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Users/neekocurious/.rvm/rubies/ruby-2.5.7/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from -e:1:in `<main>'

Я поместил gem 'devise' в свой Gemfile:

gem 'devise', '~> 4.7', '>= 4.7.1'

Мой файл model.rb выглядит следующим образом:

class Model < ApplicationRecord
  # Include default devise modules. Others available are:

      # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :validatable
    end

Я пробовал решение из другого сообщения стека и запускал 'bundle install' и 'rails generate devise: install 'снова и получил тот же длинный текст ошибки. Что мне делать или изменять, чтобы определить слово «разработать» и избавиться от этой неприятной ошибки?

...