来自模板的新rails应用程序因Desive而失败

piv4azn7  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(339)

我已经创建了一个rails应用程序模板(https://github.com/alec-c4/kickstart)我使用Desive gem作为身份验证解决方案。一切正常,但有时新的应用程序生成器会崩溃

generate  migration EnableTrgmPsqlExtension
       rails  generate migration EnableTrgmPsqlExtension
/Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `devise' for User:Class (NoMethodError)
    from /Users/alec/Temp/youre_not_alone/app/models/user.rb:6:in `<class:User>'
    from /Users/alec/Temp/youre_not_alone/app/models/user.rb:1:in `<main>'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/inflector/methods.rb:274:in `const_get'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/inflector/methods.rb:274:in `constantize'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/dependencies/zeitwerk_integration.rb:19:in `constantize'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise.rb:316:in `get'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/mapping.rb:83:in `to'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/mapping.rb:78:in `modules'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/mapping.rb:95:in `routes'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/mapping.rb:162:in `default_used_route'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/mapping.rb:72:in `initialize'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise.rb:346:in `new'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise.rb:346:in `add_mapping'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/rails/routes.rb:243:in `block in devise_for'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/rails/routes.rb:242:in `each'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/bundler/gems/devise-c82e4cf47b02/lib/devise/rails/routes.rb:242:in `devise_for'
    from /Users/alec/Temp/youre_not_alone/config/routes.rb:6:in `block in <main>'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-6.1.4/lib/action_dispatch/routing/route_set.rb:427:in `instance_exec'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-6.1.4/lib/action_dispatch/routing/route_set.rb:427:in `eval_block'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/actionpack-6.1.4/lib/action_dispatch/routing/route_set.rb:409:in `draw'
    from /Users/alec/Temp/youre_not_alone/config/routes.rb:3:in `<main>'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:47:in `block in load_paths'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:47:in `each'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:47:in `load_paths'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:21:in `reload!'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:35:in `block in updater'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/file_update_checker.rb:83:in `execute'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/routes_reloader.rb:10:in `execute'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/railties-6.1.4/lib/rails/application/finisher.rb:208:in `block (2 levels) in <module:Finisher>'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:427:in `instance_exec'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:603:in `catch'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:199:in `block in halting'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:512:in `each'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:512:in `invoke_before'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:105:in `run_callbacks'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/execution_wrapper.rb:111:in `run!'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/reloader.rb:114:in `run!'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/reloader.rb:53:in `block (2 levels) in reload!'
    from <internal:kernel>:90:in `tap'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/reloader.rb:52:in `block in reload!'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/execution_wrapper.rb:88:in `wrap'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/reloader.rb:51:in `reload!'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:168:in `serve'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
    from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
    from <internal:/Users/alec/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/Users/alec/.rbenv/versions/3.0.1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from -e:1:in `<main>'

我已经通过在user.rb文件中添加以下行解决了这个问题

extend Devise::Models

但这看起来是一个解决办法,但不是一个永久的解决办法。知道怎么修吗?

8qgya5xd

8qgya5xd1#

我想您可能需要运行生成器,以便它可以创建designe初始值设定项文件。 /config/initializers/devise.rb ```
rails generate devise:install

如果上述崩溃,您可能需要注解掉 `devise :database_authenti...` 在user.rb中输入一行,然后再次运行生成器
我正在通过电话查看您的代码,请原谅我的错误:)

相关问题