NoMethodError:AjaxDatatablesRails:Module 的未定义方法“配置”
Posted
技术标签:
【中文标题】NoMethodError:AjaxDatatablesRails:Module 的未定义方法“配置”【英文标题】:NoMethodError: undefined method `configure' for AjaxDatatablesRails:Module 【发布时间】:2021-10-22 12:59:54 【问题描述】:当我执行rake db:create
命令时,它会显示一些错误
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
NoMethodError: undefined method `configure' for AjaxDatatablesRails:Module
/home/jsmani/project-folder/config/initializers/ajax_datatables_rails.rb:3:in `<top (required)>'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `block in load'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `load'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/engine.rb:663:in `block in load_config_initializer'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/notifications.rb:170:in `instrument'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/engine.rb:662:in `load_config_initializer'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/engine.rb:619:in `each'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/engine.rb:619:in `block in <class:Engine>'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `instance_exec'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `run'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:50:in `each'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:50:in `tsort_each_child'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/initializable.rb:60:in `run_initializers'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/application.rb:361:in `initialize!'
/home/jsmani/project-folder/config/environment.rb:6:in `<top (required)>'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/bootsnap-1.7.7/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/skylight-5.1.0/lib/skylight/probes.rb:167:in `require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `block in require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `require'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/application.rb:337:in `require_environment!'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/railties-5.2.6/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/home/jsmani/.rvm/gems/ruby-2.5.3/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/jsmani/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
/home/jsmani/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)
【问题讨论】:
在ajax-datatables-rails
gem 中查看对此issue 的评论
当我评论 ajax-datatables-rails gem 时会产生名称错误
【参考方案1】:
在 gemfile 中为 AjaxDataTablesRails 提供一些特定版本,例如 (gem 'ajax-datatables-rails', '~> 1.0.0' ) 而不是像这样给出 (gem 'ajax-datatables-rails') 。 保存此更改后,让我们在终端上执行此命令(bundle install)。 现在你执行 rake db:create command 。 并执行以下命令 rake db:migrate 然后启动您的服务器 rails s
【讨论】:
以上是关于NoMethodError:AjaxDatatablesRails:Module 的未定义方法“配置”的主要内容,如果未能解决你的问题,请参考以下文章
NoMethodError:AjaxDatatablesRails:Module 的未定义方法“配置”
NoMethodError:升级到 rake 11 后未定义方法“last_comment”
NoMethodError: nil:NilClass / 'additional_paths' [capistrano+webpacker] 的未定义方法“+”