2016-11-10 2 views
0

ich den neuen Schienen-Code auf c9.io getestet auszuwählen und es funktioniert gut, den Datensatz zu wählen, wenn das emailReceived Feld auf Einladung Tabelle falsch ist,Ausfallen den Rekord in Schienen 5 Konsole

Nachdem ich die aktualisierte neuer Code in Heroku, es ist versäumt, es zu tun. Und zeigt die Fehlermeldung an.

ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "emailreceived" does not exist

Ich habe Invitation.column_names und kann die "emailReceived" finden. Ist die Datenbank beschädigt? Hier finden Sie die Konsoleninformationen als Referenz. Bitte helfen Sie bei der Fehlerbehebung.

irb(main):005:0> Invitation.column_names 
=> ["id", "church", "telephone1", "telephone2", "worshipTime", "contactName", "contactNumber", "priest", "preacher", "emailReceived", "acceptPromote", "promotionTime", "other", "created_at", "updated_at"] 
irb(main):006:0> Invitation.where("emailReceived = false") 
Invitation Load (3.0ms) SELECT "invitations".* FROM "invitations" WHERE (emailReceived = false) 
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "emailreceived" does not exist 
LINE 1: SELECT "invitations".* FROM "invitations" WHERE (emailReceiv... 
^ 
HINT: Perhaps you meant to reference the column "invitations.emailReceived". 
: SELECT "invitations".* FROM "invitations" WHERE (emailReceived = false) 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in async_exec' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:598:inblock in exec_no_cache' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in block in log' 
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:ininstrument' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:560:in log' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:598:inexec_no_cache' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:585:in execute_and_clear' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:inexec_query' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:373:in select' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:41:inselect_all' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in select_all' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/querying.rb:39:infind_by_sql' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:699:in exec_queries' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:580:inload' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:260:in records' 
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:683:ininspect' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in start' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:instart' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in console' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:inrun_command!' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in <top (required)>' 
from bin/rails:8:inrequire' 
from bin/rails:8:in `'irb(main):007:0> 

Eine weitere Informationen zu diesem Fall, ich laufe "Heroku Rake --trace db laufen: wandern VERSION = 20161007083159" und das folgende Ergebnis. Und es funktioniert immer noch nicht

heroku run rake --trace db:migrate VERSION=20161007083159 
Running rake --trace db:migrate VERSION=20161007083159 on ⬢ shrouded-scrubland-30708... up, run.1694 
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Invoke db:load_config (first_time) 
** Execute db:load_config 
** Execute db:migrate 
    ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations" 
    ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations" 
    (0.5ms) SELECT pg_try_advisory_lock(129277373589159705); 
    ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations" 
    ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]] 
    (0.5ms) BEGIN 
    (0.4ms) COMMIT 
    (0.5ms) SELECT pg_advisory_unlock(129277373589159705) 
** Invoke db:_dump (first_time) 
** Execute db:_dump 

Dank

Patrick Lee

+0

Können Sie uns die Rails Active Abfrage im Code zeigen? – meshpi

+0

Haben Sie kürzlich Migrationen durchgeführt? –

+0

versuchen Sie 'Einladung.where (: emailReceived => false)' –

Antwort

0

Schließlich fand ich, dass das Problem aufgrund der Fall aufgetreten ist empfindlich von postgresql. Also habe ich den Code von Invitation.where("emailReceived is ? OR emailReceived = ?", nil,false) zu Invitation.where("emailReceived" => nil) am Modell geändert.

Aber noch eine Frage, wie kann man OR für Invitation.where("emailReceived" => nil)Invitation.where("emailReceived" => false) verwenden?

Dank

Patrick Lee

+0

Schließlich funktioniert diese Einladung.where ("emailReceived" => [nil, false]) **. –