草庐IT

resDetail_pg

全部标签

ruby-pg 在插入之前清理数据

这里是Ruby新手。我正在尝试插入此字符串“LadyArabella'sScandalo...”我正在使用ruby​​-pg来执行此操作。但是由于单引号我有错误,我怎样才能清理这个字符串并删除所有html标签?是否有内置函数? 最佳答案 您可以使用escape_string正确转义你的单引号:db=PG.connect(...)db.exec("insertintot(...)values('#{db.escape_string(str)}',...)")或使用prepare和exec_prepared改为使用准备好的语句:db.p

ruby - Heroku 数据库 :pull Taps Load Error: no such file to load -- pg

我在使用ruby​​1.9.2-p320和Heroku的Taps时遇到了以下错误-使用“db”命令,例如:herokudb:pull--appmy-app这会产生如下错误:TapsLoadError:nosuchfiletoload--sqlite3-或-TapsLoadError:nosuchfiletoload--pg(是的,顺便说一句,我拥有所有正确的gems,包括postgres——在本地运行良好——和sqlite3,以及卸载、重新安装和更新taps和herokugems并将它们包括为以及不将它们包含在我的Gemfile中。我正在运行Rails3.2.6)尽管有一个导致“时区偏

ruby-on-rails - pg gem install 失败说版本太旧?

我正在尝试为Ruby安装pg(PostreSQL)gem。我收到此错误:postgres/9.2-pgdg/bin/64/pg_configUsingconfigvaluesfrom/location/to/install/postgres/9.2-pgdg/bin/64/pg_configcheckingforlibpq-fe.h...yescheckingforlibpq/libpq-fs.h...yescheckingforpg_config_manual.h...yescheckingforPQconnectdb()in-lpq...yescheckingforPQconnec

ruby-on-rails - pg_search 使用 associated_against 给出错误 "column [model_name].[associated_column_name] does not exist"

我正在尝试使用pg_search来搜索关联模型。当我运行搜索时,出现错误“PG::Error:ERROR:columnplans.namedoesnotexist”。我正在“计划”模型中运行搜索,并尝试针对“地点”与列“名称”的关联进行搜索。连接这些的has_many:through模型是多态的。不知何故,sql查询将两者结合起来并抛出错误。我已经运行了associated_against迁移(railsgpg_search:migration:associated_against),搜索了文档,并寻找其他有错误的人,但一无所获,一定是我只是忽略了一些东西。如果我只是删除plan.rb

ruby-on-rails - gem install pg 在 OSX 10.9 上失败

这个问题在这里已经有了答案:Rails:InstallingPGgemonOSX-failuretobuildnativeextension(15个答案)关闭7年前。运行bundleinstall(或geminstallpg)时出现以下错误我已经尝试修复xcode命令行工具/Users/josh/.rvm/rubies/ruby-2.0.0-p353/bin/rubyextconf.rbcheckingforpg_config...noNopg_config...tryinganyway.Ifbuildingfails,pleasetryagainwith--with-pg-confi

ruby-on-rails - 安装pg(0.19.0)时出错,Bundler无法继续

昨天我安装了Ubuntu16.04.1。ruby2.3.1p112(2016-04-26修订版54768)[x86_64-linux]rails-v'4.2.6'创建一个Rails项目运行bundle出现错误:Errno::EACCES:Permissiondenied@rb_sysopen-/home/zeus/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.19.0/.gemtestAnerroroccurredwhileinstallingpg(0.19.0),andBundlercannotcontinue.Makesur

ruby-on-rails - Rails 4 ActiveRecord 在 Ubuntu 13.04 上抛出 PG::UnableToSend

我们有一个Rubyv.2.0.0-p247在Railsv4.0.1应用程序使用pggemv0.17.0.应用在MacOSXMavericksv10.9下顺利运行与PostgreSQLServerv9.2.4使用HomeBrew安装但它在Ubuntuv13.04下抛出以下异常使用PostgreSQLServer9.1:PG::UnableToSend:serverclosedtheconnectionunexpectedlyThisprobablymeanstheserverterminatedabnormallybeforeorwhileprocessingtherequest.异常发

ruby - pg gem : 'Warning: no type cast defined for type "numeric"'

我在从pggem中获取输入结果时遇到问题。require'pg'require_relative'spec/fixtures/database'client=PG.connect(DB[:pg])client.type_map_for_queries=PG::BasicTypeMapForQueries.new(client)client.type_map_for_results=PG::BasicTypeMapForResults.new(client)client.exec(%|select*fromtestme;|)do|query|query.each{|r|putsr.ins

ruby-on-rails - Heroku:PG::错误:错误:关系的权限被拒绝

每次我尝试将某些内容保存到数据库中时,都会收到此错误消息。我看到Heroku为前10.000条记录提供免费的PostgreSQL数据库,超过10.000条记录需要支付数据库费用。现在,我的数据库中大约有60.000条记录。如何修复该错误/升级数据库?提前致谢 最佳答案 您需要使用PGBackups附加组件来备份您的数据库,然后从您的开发/基本计划迁移到生产级(付费)计划。它的缺点:提供新的生产级HerokuPostgresql计划将您的应用置于维护模式以防止新的更新获取备份恢复到升级后的数据库将新数据库提升为主重新激活您的应用htt

ruby - 安装 pg gem 时遇到问题

尝试安装pggem时出错。我使用的是使用rbenv/ruby-build构建的Ruby1.9.3-p125。我使用一键安装程序安装了PostgreSQL。我可以使用pgAdmin连接到数据库。我的想法用完了。%geminstallpg~Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingpg:ERROR:Failedtobuildgemnativeextension./Users/sandropadin/.rbenv/versions/1.9.3-p125/bin/rubyextconf.rbcheck