草庐IT

pg_config

全部标签

ruby-on-rails - 如何修复 PG::DuplicatePstatement: ERROR?

我想知道如何防止此类错误。到目前为止,我尝试通过AWSOpsworks的数据库配置禁用准备好的语句:例如:数据库配置},"deploy":{"app_name":{"database":{"adapter":"postgresql","prepared_statements":false,"username":"username","database":"db_name_production","host":"cool_host.com","password":"easy"},错误日志PG::DuplicatePstatement:ERROR:preparedstatement"a6"

ruby-on-rails - 为什么 Rails 生成运行类而不是对象的 config.ru?

RackspecifiesARackapplicationisaRubyobject(notaclass)thatrespondstocall.因此,一个简单的config.ru看起来像这样:classMyAppdefcall(env)[200,{"Content-Type"=>"text/plain"},["HellofromRack!\n"]]endendrunMyApp.new当Rails生成这个时:#ThisfileisusedbyRack-basedserverstostarttheapplication.require::File.expand_path('../confi

ruby-on-rails - Rspec.config 之前(:each) except for specific :types

我正在尝试获取一个before(:each)block以针对所有规范excepttype::feature运行。我让它工作的唯一方法是剪切和粘贴,并为每种类型设置单独的配置block。(:type=>:model,:type=>:service等)spec/rails_helper.rb#Tospeeduptests,stuballPaperclipsavingandreadingto/fromS3config.before(:each,:type=>:model)doallow_any_instance_of(Paperclip::Attachment).toreceive(:sav

ruby - pg_dump : [archiver (db)] query failed: ERROR: permission denied for relation abouts

我正在尝试转储我的pgdb但遇到这些错误请建议pg_dump:[archiver(db)]queryfailed:ERROR:permissiondeniedforrelationaboutspg_dump:[archiver(db)]querywas:LOCKTABLEpublic.aboutsINACCESSSHAREMODE 最佳答案 您正在执行pg_dump的用户没有公共(public)模式的权限。如果允许则添加权限:GRANTUSAGEONSCHEMApublicTO;GRANTSELECTONALLTABLESINSCH

ruby-on-rails - 如何防止 Rails Controller 生成器修改 config/routes.rb

有时我会运行类似railsgcontrollerfooindex的命令来生成Controller和模板的骨架。因为我不希望每个Controller都有助手和Assets,所以我将以下代码放入config/application.rb:config.generatorsdo|g|g.helperfalseg.assetsfalseend还有一件事我不想发生。生成器将一行get"foo/index"添加到我的config/routes.rb。我该如何预防? 最佳答案 从Rails4.2开始,可以在application.rb中使用以下代

ruby - 使用 ruby​​ pg gem 准备好的 INSERT 语句示例

谷歌搜索了大约半天,我找不到任何使用pggem(postgresqlruby​​gem)准备好的INSERT语句的示例。我试过了(在查看了gem文档之后):deftest2conn=PG.connect(dbname:'db1')conn.prepare("statement1",'INSERTINTOtable1(id,name,profile)VALUES(?,?,?)')end但是我得到以下错误:pgtest.rb:19:in`prepare':ERROR:syntaxerroratornear","(PG::Error)LINE1:INSERTINTOtable1(id,nam

ruby-on-rails - 自定义 rails has_many 关联(通过 pg 数组)

所以基本上我想知道是否有一些通用方法来定义自己的关联类型。一些细节:我有一个模型conversations有一个PG数组列user_ids.因此,要检索我需要运行的用户对话:selectconversations.*fromconversationswhereUSER_ID=ANY(conversations.user_ids)自finder_sql它的friend现在已被弃用,我真的很想知道实现这个伪has_many关联的最佳方法是什么?目前我只使用如下方法:defconversationsConversation.where("#{id}=ANY(conversations.use

ruby-on-rails - 将 PG::Result 转换为 Active Record 模型

pg-ruby允许您一次性向数据库发送多个查询,这有助于最大限度地减少访问数据库的次数:results=[]conn.send_query('QUERY1;QUERY2;QUERY3')conn.blockwhileresult=conn.get_resultresults假设对于任何result我已经知道ActiveRecord模型,将结果转换为模型的合适方法是什么?现在我正在做以下事情:fields=result.fieldsmodels=result.values.map{|value_set|Model.new(Hash[fields.zip(value_set)])}该方法的

ruby-on-rails - `secret_token` 环境缺少 `secret_key_base` 和 'development',在 `config/secrets.yml` 中设置这些值

当我尝试运行railsserver命令时出现错误如何解决?我的config/environments/development.rbRails.application.configuredoconfig.secret_key_base=ENV["SECRET_KEY_BASE"]#Somestuffend而且我的文件夹中没有secret.yml文件。 最佳答案 然后创建一个:配置/secrets.yml#besuretorestartyourserverwhenyoumodifythisfile...#Makesurethesecre

ruby-on-rails - 在 osx 上安装 pg gem 时出错

我在osx10.6.7上尝试在新的Rails3.0.7应用程序上运行bundleinstall,但在尝试构建pggem时它一直失败。它一直告诉我我需要开发者工具。但据我所知,我已经安装了开发人员工具。这是xcodebuild-version的输出Xcode3.2.6Componentversions:DevToolsCore-1809.0;DevToolsSupport-1806.0BuildVersion:10M2518这是失败的pggem构建的输出/Users/bm/.rvm/rubies/ruby-1.9.2-head/bin/rubyextconf.rb--with-pg-co