我有一个5.0.1没有任何数据库支持的Rails 应用程序.尝试编写控制器测试时,ActiveRecord::ConnectionNotEstablished即使我已明确配置我spec/rails_helper.rb不使用ActiveRecord和删除对active_record的引用,我也会收到异常config/application.rb.RSpec正试图在需要建立数据库连接的事务中运行此类测试.我附加堆栈跟踪以供参考,我使用此Github问题来设置RSpec而不使用ActiveRecord rspec-rails用于没有数据库连接的rails项目.
失败:
1)ApplicationController真值假不等于true失败/错误:引发ConnectionNotEstablished,"找不到ID#{spec_name}的连接池." 除非游泳池
ActiveRecord::ConnectionNotEstablished:
No connection pool with id primary found.
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `retrieve_connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_handling.rb:91:in `connection'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:516:in `create_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:1015:in `load_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:988:in `setup_fixtures'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/activerecord-5.0.1/lib/active_record/fixtures.rb:852:in `before_setup'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-rails-3.6.1/lib/rspec/rails/adapters.rb:126:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:375:in `execute_with'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:342:in `call'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /home/vagrant/.bundle/easypost_admin/ruby/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:464:in `run'
# …Run Code Online (Sandbox Code Playgroud) ruby-on-rails rspec-rails rails-activerecord ruby-on-rails-5 no-database
我正在使用react-paginate库,它效果很好。
我没有找到只显示正确链接的方法。像这样的东西:
与默认值相反:
这只是我想在我的应用程序中完成的一个小细节,但我认为使用当前的 api 无法做到这一点。
有什么解决办法吗?
我在我的项目中使用acts_as_votable gem。由于某些奇怪的原因,我无法访问中的Vote模型表Rails console。我重新加载了development环境,甚至重新启动了计算机。
我可以upvote一个模型和get_upvotes.size投票模型。
我想做一些专门的查询,例如Vote.where(...)。当我尝试Vote.all在Rails控制台中查询时,出现错误。顺便说一下,我正在使用postgresql进行开发。
2.0.0-p353 :007 > Vote.all
NameError: uninitialized constant Vote
Run Code Online (Sandbox Code Playgroud)
该Vote模型存在于我的模型中,schema.rb而不存在于中app/models。该Vote表位于pgAdmin中。提前致谢。