当我运行rake db:seed时,我收到一个错误,我假设可能与日期对象有关,这些对象是我在seeds.rb中创建的模型上的属性。如果这是原因,有办法解决吗?这是错误输出:
rake aborted!
PG::InvalidTimeZoneDisplacementValue: ERROR: time zone displacement out of range: "-4712-01-01"
: INSERT INTO "courses" ("code", "created_at", "description", "end_on", "image_content_type", "image_file_name", "image_file_size", "image_updated_at", "instructor_token", "name", "public", "school", "start_on", "student_token", "syllabus", "ta_token", "term", "updated_at", "year") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) RETURNING "id"
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1174:in `get_last_result'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1174:in `exec_cache'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `block in exec_query'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/relation.rb:66:in `insert'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/persistence.rb:367:in `create'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/timestamp.rb:58:in `create'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/callbacks.rb:268:in `block in create'
/Users/evankline/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:403:in `_run__2393321980833873965__create__2992353098426140512__callbacks'
我已经看到了与Heroku相关的这个错误,但没有关于它在本地机器上发生的事情。大多数答案都与切换到Ruby 1.9.2有关,然而,这会引发错误,因为我在应用程序中使用的几个宝石需要Ruby 1.9.3或更高版本。非常感谢任何帮助,谢谢!
答案 0 :(得分:1)
PostgreSQL没有将Date识别为有效输入。通过更改以下内容:
Date.new(2014,1,17)
为:
Date.parse("2014-1-17")
我能够获得填充数据库的种子。