jjzjj

pg_attribute

全部标签

ruby-on-rails - Rails 无法登录到 postgresql - PG::Error - 密码 - 正确信息

这是我的database.yml文件的样子(显然还有用于测试和生产的相关条目)development:adapter:postgresqlencoding:unicodedatabase:dbname_devpool:5username:usernamepassword:tehpass在终端中,我可以成功运行以下命令并登录到数据库:psql-Uusernamedbname_dev但是在创建这个新的Rails项目并运行之后railsgcontrollerComingSoonindex当我转到localhost:3000/coming_soon时收到以下消息(尽管对登录凭据进行了双重和三次

ruby-on-rails - sudo gem install pg 不起作用

我正在尝试让Rails与PostgreSQL一起工作。显然,我一路上需要做的一件事是sudogeminstallpg。当我这样做时,我得到了这个:jason@buster:~/projects$sudogeminstallpgBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingpg:ERROR:Failedtobuildgemnativeextension./usr/bin/ruby1.8extconf.rbextconf.rb:2:in`require':nosuchfiletoload--mkmf(

ruby-on-rails - Rails 3.2 Postgres 保存错误 "ActiveRecord::StatementInvalid: PG::Error: ERROR: Syntax error near ' T' 在位置 5"

当我尝试将特定类保存到数据库时,我的应用开始抛出错误。我不确定到底是什么原因导致这种情况开始发生-过去几天我一直遇到各种数据库问题....无论如何,我的模型似乎工作正常(它正在正确计算所有before_save值),但随后它尝试保存到数据库并爆炸。SQL(0.8ms)INSERTINTO"portfolios"("correlation_matrix","created_at","data","mean_return","std_dev","updated_at","weights")VALUES($1,$2,$3,$4,$5,$6,$7)RETURNING"id"[["correla

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

我正在尝试在Rails中创建数据库。在Postgres中,我看到了开发和测试数据库,但是,我遇到了权限错误。我试过点击此链接,但对我不起作用。错误:PG::InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝:SELECT"schema_migrations".*FROM"schema_migrations"Rails:permissiondeniedforrelationschema_migrationsdefault:&defaultadapter:postgresqlencoding:unicodepool:5host:localh

ruby-on-rails - 警告 : Can't mass-assign protected attributes

当发帖到/:username/about时,我收到“警告:无法批量分配protected属性:about”。classAbout["lower(username)=?",params[:username].downcase])iftrue@about=@user.aboutif@about.update_attributes(params[:about])flash[:notice]="Successfullyupdatedpost."respond_with(@about,:location=>about_path(@about.user.username))elseredirect

ruby-on-rails - 切换到 Rails 4.1 时出现错误 - `method_missing':ActiveRecord::Base:Class (NoMethodError) 的未定义方法 `whitelist_attributes='

从Rails4.0切换到Rails4.1时出现此错误:activerecord-4.1.8/lib/active_record/dynamic_matchers.rb:26:in`method_missing':undefinedmethod`whitelist_attributes='forActiveRecord::Base:Class(NoMethodError)我没有在我的应用程序的任何地方使用attr_accessible或attr_protected所以我想知道为什么我有问题。当迁移到Rails4.0时,我已经安装了我的application.rb:配置/应用程序.rb:c

ruby-on-rails - rails : Copying attributes from an object to another using the "attributes" method

让模型Quote具有属性[price,description]让模型Invoice有属性[price,description,priority]让invoice模型Invoice中的对象具有属性{price:10,description:'lamp',priority:10}invoice={price:10,description:'lamp',priority:10}假设我想将invoice属性复制到新的quote。quote=Quote.new(invoice.attributes)这会引发一个错误,即priority在模型Quote中不存在。如何将invoice属性复制到新的q

ruby-on-rails - 无法在 Rails 上安装 pg gem

我正在尝试捆绑安装,但是由于某些奇怪的原因,pggem在安装时返回了以下错误:$geminstallpg-v'0.18.4'Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingpg:ERROR:Failedtobuildgemnativeextension./Users/username/.rvm/rubies/ruby-2.2.1/bin/ruby-r./siteconf20151221-23315-1tkv3fd.rbextconf.rbcheckingforpg_config...noNopg_c

ruby-on-rails - 如何修复 Rails 中 pg_attribute 表的缓慢隐式查询

在我们的生产环境中,我们注意到Rails应用程序频繁出现峰值(大约每1小时一次)。深入挖掘,这是由于以下查询在单个HTTP请求中累计运行时间超过1.5秒(称为100倍)。SELECTa.attname,format_type(a.atttypid,a.atttypmod),pg_get_expr(d.adbin,d.adrelid),a.attnotnull,a.atttypid,a.atttypmodFROMpg_attributeaLEFTJOINpg_attrdefdONa.attrelid=d.adrelidANDa.attnum=d.adnumWHEREa.attrelid=

ruby-on-rails - 在模型中使用 self.attribute 和 attribute 有什么区别?

在RubyonRails中,在模型中使用self.attribute和attribute有什么区别?在此示例中,假设my_attr是存储在数据库中的用户属性。classUser 最佳答案 您的示例的不同之处在于第一个有效,第二个无效。您的第二个版本没有做任何事情(至少没有任何意义)。编写my_attr=123不等同于self.my_attr=123。相反,它会创建一个名为my_attr的局部变量并将其设置为123,然后立即到达方法的末尾并丢弃my_attr。整个方法本质上是一个no-op,它不会以任何方式影响模型的my_attr值。