当前位置: 首页 > 面试题库 >

ActiveRecord :: StatementInvalid。PG错误

况谦
2023-03-14
问题内容

我正在尝试从Project使用的模型中找到一个项目,Project.find(id)但这给了我ActiveRecord::StatementInvalid错误

全程跟踪

 PG::Error: ERROR: prepared statement "a1" already exists : SELECT COUNT(*) FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind in ('v','r') AND c.relname = $1 AND n.nspname = ANY (current_schemas(false))
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1180:in `prepare'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1180:in `prepare_statement'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1144:in `exec_cache'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-     3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in `block in exec_query'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:662:in `exec_query'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:797:in `table_exists?'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/connection_adapters/schema_cache.rb:30:in `table_exists?'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:223:in `table_exists?'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/attribute_methods/primary_key.rb:75:in `get_primary_key'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/attribute_methods/primary_key.rb:60:in `reset_primary_key'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/attribute_methods/primary_key.rb:49:in `primary_key'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:230:in `block in columns'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `map'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `columns'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:237:in `columns_hash'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/relation/delegation.rb:7:in `columns_hash'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:330:in `find_one'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:311:in `find_with_ids'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:107:in `find'
/home/deploy/.rvm/gems/ruby-1.9.2-p290@submit_contactpl/gems/activerecord-3.2.2/lib/active_record/querying.rb:5:in `find'
/home/deploy/submit_contactpl/app/workers/php_worker.rb:5:in `perform'

的第5行php_worker

 project = Project.find(project_id)

可能是什么问题?您可以在上面遮一下光吗?可能的解决方案是什么


问题答案:

它所需要的只是

 task "resque:setup" => :environment do
  #ENV['QUEUE'] = '*'

  Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
 end

在您的resque.rake文件中



 类似资料:
  • 我正在尝试为我的Devise User模型添加一些额外的信息,如first_name、last_name、年龄、性别和城市。 当我填写注册表格并单击提交时,我会收到以下错误: SQLite3::ConstraintExc的:不是NULL约束失败:users.first_name:插入到用户(电子邮件,encrypted_password,created_at,updated_at)值 (?, ?,

  • 我刚刚在我的RefineryCMS Rails 3.2.3应用程序中安装了newrelic\u rpm gem。我抄了这件新文物。按照说明的yml配置文件。我的应用程序在Cedar堆栈上部署了Heroku,所以说明非常简单。 https://devcenter.heroku.com/articles/newrelic#cedar 但是,在我的开发盒上运行“rails server”时,会显示以下错

  • ActiveRecord 是个轻量级的核心数据的活动记录。

  • PG

    Concepts Peering Interval See PG::start_peering_interval. See PG::acting_up_affected See PG::RecoveryState::Reset A peering interval is a maximal set of contiguous map epochs in which the up and actin

  • pg

    pg 是一个用于golang database/sql 的 PostgreSQL 驱动。 安装 go get github.com/blusewang/pg 使用 db, err := sql.Open("pg", "pg://user:password@dbhost.yourdomain.com/database_name?application_name=app_name&sslmode=v

  • Castle ActiveRecord框架是一个基于.NET的ORM框架,它实现了ActiveRecord设计模式。它本身就是基于NHibernate,只是封 装了NHibernate的大部分烦杂细节,对于需要持久化的类,只需继承自ActiveRecordBase类,并对类中的property赋予正确的 Attribute,而无需编写烦杂的mapping file。对于大型系统复杂的数据库逻辑,C