草庐IT

PostgresQL

全部标签

sql - ActiveRecord::StatementInvalid。 PG错误

我正在尝试使用Project.find(id)从Project模型中找到一个项目,但它给了我ActiveRecord::StatementInvalid错误完整跟踪-PG::Error:ERROR:preparedstatement"a1"alreadyexists:SELECTCOUNT(*)FROMpg_classcLEFTJOINpg_namespacenONn.oid=c.relnamespaceWHEREc.relkindin('v','r')ANDc.relname=$1ANDn.nspname=ANY(current_schemas(false))/home/deploy

ruby-on-rails - PG::TRDeadlockDetected:错误:检测到死锁

我正在通过bundleexecpumactl-Fconfig/puma.rbphased-restart重新启动8个pumaworker,效果很好。现在我收到越来越多的postgres错误:PG::TRDeadlockDetected:ERROR:deadlockdetected我发现大约有50个空闲的postgres进程在运行:postgres:myappmyapp_production127.0.0.1(59950)idlepostgres:myappmyapp_production127.0.0.1(60141)idle...当我运行bundleexecpumactl-Fconf

ruby-on-rails - Rails ActiveRecord:PG::错误:错误:列引用 "created_at"不明确

我正在努力解决对象中的错误,但完全不确定问题出在哪里。这是模型的样子:classCar:car_colorsendclassCarColor:car_colorsend这里是查询:@cars=Car.all(:joins=>:car_colors,:conditions=>{:car_colors=>{:color_id=>params[:id_number]}},:order=>"cars.created_atDESC")错误输出:PG::Error:ERROR:columnreference"created_at"isambiguousLINE1:...d"WHERE"car_co

ruby-on-rails - Rails Resque 工作人员因 PGError : server closed the connection unexpectedly 失败

我在Ubuntu9.10、Rails2.3.4、ruby-ee2010.01、PostgreSQL8.4.2上有站点运行rails应用程序和在生产模式下运行的resqueworkerWorkers不断报错:PGError:serverclosedtheconnectionunexpectedly.我最好的猜测是masterresque进程建立了与db的连接(例如,authlogic在使用User.acts_as_authentic时会这样做),同时加载Rails应用程序类,并且该连接在fork()ed进程(退出时?)中被破坏,所以下一个fork的child会得到一种splinter的全

ruby-on-rails - 如何更改 Heroku 中的列类型?

我正在尝试将db:migrations放入我的heorku实例中,但出现错误。常见问题解答如下描述了我的错误:CannotchangecolumntypeExample:PGError:ERROR:column“verified_at”cannotbecasttotype“date”Cause:PostgreSQLdoesn’tknowhowtocastalltherowsinthattabletothespecifiedtype.Mostlikelyitmeansyouhaveanintegerorastringinthatcolumn.Solution:Inspectyourrec

ruby - Heroku Rails 4 无法连接到服务器 : connection refused

使用postgres。一直推不开。没有任何运气尝试过:config.assets.initialize_on_precompile=false----->PreparingappforRailsassetpipelineRunning:rakeassets:precompilerakeaborted!couldnotconnecttoserver:ConnectionrefusedIstheserverrunningonhost"127.0.0.1"andacceptingTCP/IPconnectionsonport5432? 最佳答案

ruby-on-rails - Rails 4 迁移 : has_and_belongs_to_many table name

我目前正在尝试将Rails3.2应用程序切换到Rails4.0。但是我对has_and_belongs_many模型有一个问题。我创建了一个测试应用程序,但我遇到了同样的问题。这就是我所做的:创建了两个模型:foo_clip和foo_urlclassFooClip在此之后我更新了迁移文件:classCreateFooClips现在我已经为has_and_belongs_to_many表创建了迁移文件classCreateFooClipsFooUrls作为最后一步,我创建了一个用于测试的种子文件:foourl1=FooUrl.create!(:url=>'http://www.googl

我不仅需要一排postgresql

我需要一个可以返回比一行更多的后Ql子查询。这是我到目前为止的查询部分:select(SELECTARRAY[url,thumb_1,thumb_200,thumb_500]FROM"Image"LEFTJOIN"Product_Image"ON"Image".id="Product_Image".image_idWHERE"Product_Image".product_id=517ORDERBY"Product_Image".sortASC)asimages看答案将子查询放在FROM条款?selectvalsfrom(SELECTARRAY[url,thumb_1,thumb_200,thu

ruby-on-rails - 升级到 OSX Mavericks 后修复 postgresql

最近升级到OSXMavericks中断了我的Rails应用程序的数据库连接。当我尝试从数据库中获取数据时,服务器返回以下错误:PG::ConnectionBad(couldnotconnecttoserver:ConnectionrefusedIstheserverrunningonhost"localhost"(::1)andacceptingTCP/IPconnectionsonport5432?couldnotconnecttoserver:ConnectionrefusedIstheserverrunningonhost"localhost"(127.0.0.1)andacce

ruby-on-rails - 安装 pg gem 失败, "mkmf.rb can' t 找不到 ruby​​ 的头文件”(Mac OSX 10.6.5)

我刚刚升级到Rails3,在使用MacPorts、gems和数据库时遇到了一些麻烦,需要解决。我扔掉了所有的gem并重新安装它们。除了pggem的要求外,一切似乎都正常。在为PostgreSQL创建一个新的Rails3项目后,服务器无法启动,提示缺少pggem。在执行bundleinstall时,它运行了一段时间,当然,在pggem上失败了。Installingpg(0.10.0)withnativeextensions/Library/Ruby/Site/1.8/rubygems/installer.rb:483:in`build_extensions':ERROR:Failedto