虚拟交易杀死ActiveRecord? Rails无法读取任何数据

时间:2019-01-08 02:08:33

标签: ruby-on-rails ruby-on-rails-5 rails-activerecord rubymine

启动控制台或启动开发中的项目时,每当尝试触摸postgres db时都会收到此错误,但是错误消息中引用的文件在我的项目中不再存在。 (... app.workflows / user_workflow)。我分别将文件名和类名分别更改为intuit_user_workflow.rb和IntuitWorkflow

 bash -c "/Users/yus3/.rvm/bin/rvm ruby-2.5.0 do /Users/yus3/.rvm/rubies/ruby-2.5.0/bin/ruby /Users/yus3/.rvm/gems/ruby-2.5.0/gems/ruby-debug-ide-0.7.0.beta6/bin/rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 49430 --host 0.0.0.0 --dispatcher-port 49431 -- \"/Users/yus3/Documents/Mac 11.18/RubymineProjects/CostReportQB/bin/rails\" console"
Fast Debugger (ruby-debug-ide 0.7.0.beta6, debase 0.2.3.beta2, file filtering is supported) listens on 0.0.0.0:49430
Loading development environment (Rails 5.2.1)
2.5.0 :001 > >> p=Project.first
Traceback (most recent call last):
        1: from (irb):1
SyntaxError (/Users/yus3/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:257: syntax error, unexpected tSYMBEG, expecting keyword_end
...app/workflows/user_workflow.rb:19
...                              ^
/Users/yus3/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:273: dynamic constant assignment
        NULL_TRANSACTION = NullTransaction.new
                         ^
/Users/yus3/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:283: syntax error, unexpected end-of-input, expecting keyword_end)
2.5.0 :002 > 

每当我尝试执行需要activerecord的任何操作时,都会执行此操作。失败,并显示类似的错误消息。

奇怪的是,所引用的唯一文件不是任何库的一部分... app / workflows / user_work.rb:19已不在我的项目中(尽管以前是)。我在项目中出现的任何地方都将文件和类的名称更改为IntuitUserWorkflow,这一点得到了我代码基础的全面确认。不过,我仍然会基于不存在的文件收到此错误。另一个值得注意的问题是,在文件中,我有一条语句User.transaction do..end块,在重命名之前,该语句曾经存在于文件中,但是我也删除了事务代码。

这是我为解决该问题而尝试做的一些事情。

  • 重新启动服务器
  • 退出开发环境,使缓存无效,然后重新启动
  • 重新启动我的机器
  • 尝试使用删除和重新创建数据库 rake db:drop(db:drop失败,出现类似错误)
    • 停止并重新启动postgres
    • 清洗并重新捆扎所有宝石。

我还能够通过sql控制台直接访问数据库而无需使用rails。没问题。

环境就是Rails 5.2.1 Ruby 2.5 Activerecord-5.2.1

建议的补救措施?

0 个答案:

没有答案