使用:Rails 3.0.3和Heroku with Postgresql。PGError:錯誤:當前事務中止
我已經收到許多例外,如這一個:
A ActiveRecord::StatementInvalid occurred in home#index:
PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT "calculation_types".* FROM "calculation_types"
.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `rescue in log'
發生的歷史althroughout我的應用程序,但總是當我執行在這種情況下
calculation_type = CalculationType.find(params[:id])
或類似的,超級簡單,數據庫 - 要求。
我的寶石(從我上傳它的Heroku)的名單:
Installing rake (0.9.2.2)
Installing abstract (1.0.0)
Installing activesupport (3.0.3)
Installing builder (2.1.2)
Installing i18n (0.6.1)
Installing activemodel (3.0.3)
Installing erubis (2.6.6)
Installing rack (1.2.5)
Installing rack-mount (0.6.14)
Installing rack-test (0.5.7)
Installing tzinfo (0.3.33)
Installing actionpack (3.0.3)
Installing mime-types (1.19)
Installing polyglot (0.3.3)
Installing treetop (1.4.10)
Installing mail (2.2.19)
Installing actionmailer (3.0.3)
Installing arel (2.0.10)
Installing activerecord (3.0.3)
Installing activeresource (3.0.3)
Installing acts_as_tree_rails3 (0.1.0)
Installing breadcrumbs_on_rails (2.2.0)
Installing yamler (0.1.0)
Installing configatron (2.9.1)
Installing daemons (1.1.9)
Installing eventmachine (1.0.0) with native extensions
Installing exception_notification (2.4.1)
Installing friendly_id (4.0.0.beta12)
Installing i18n_routing (0.6.1)
Installing thor (0.14.6)
Installing railties (3.0.3)
Installing jquery-rails (1.0.19)
Installing pg (0.14.1) with native extensions
Installing postgres-pr (0.6.3)
Installing rack-rewrite (1.0.2)
Installing rack-timeout (0.0.3)
Using bundler (1.0.7)
Installing rails (3.0.3)
Installing thin (1.5.0) with native extensions
Installing time_diff (0.2.2)
事實
- 的錯誤是間歇性的,我不能複製它們。
- 似乎在大部分時間發生時,搜索引擎機器人試圖訪問該頁面
問題
Q1。我甚至不知道從哪裏開始解決這個問題(我需要哪些其他代碼部分?)。我的第一步應該是什麼? Q2302。 Rails 3.0.3和Postgresql有什麼已知的問題嗎?
- 你需要幫我排查什麼?
在'params'之前刪除':',它應該讀取'calculation_type = CalculationType.find(params [:id])' – nmott
謝謝,但實際上這只是文本中的o複製和粘貼),以便代碼中實際不存在。我現在已經從我的問題中刪除了它。 – Christoffer
如果u [R使用ActiveRecord ::交易則結賬http://apidock.com/rails/ActiveRecord/Transactions/ClassMethods –