Rails Production - Works但无法编辑/删除/创建记录?

时间:2015-03-24 00:40:30

标签: javascript ruby-on-rails unicorn production

经过大量的第一次头痛,我终于在网上部署了我的网站,耶! :)

我可以很好地查看网站,但我无法创建/编辑或删除任何记录。我的研究告诉我,它与处理create / update / destroy请求的javascript有关,但我找不到解决方案。也许它甚至与javascript无关。

给出的错误信息表示"我们很抱歉,但出了点问题。"检查日志。

我的生产日志说:

admin@The-Origin-of-Foods:/home/rails/log$ tail production.log
I, [2015-03-22T11:31:48.832680 #25012]  INFO -- : Completed 200 OK in 13ms (Views: 9.7ms | ActiveRecord: 0.7ms)
I, [2015-03-22T11:31:49.647607 #25012]  INFO -- : Started GET "/foods" for 127.0.0.1 at 2015-03-22 11:31:49 -0400
I, [2015-03-22T11:31:49.648373 #25012]  INFO -- : Processing by FoodsController#index as HTML
D, [2015-03-22T11:31:49.649507 #25012] DEBUG -- :   Food Load (0.3ms)  SELECT "foods".* FROM "foods"
D, [2015-03-22T11:31:49.650502 #25012] DEBUG -- :   Food Load (0.3ms)  SELECT "foods".* FROM "foods"  ORDER BY name ASC
D, [2015-03-22T11:31:49.651289 #25012] DEBUG -- :   CACHE (0.0ms)  SELECT "foods".* FROM "foods"
I, [2015-03-22T11:31:49.652546 #25012]  INFO -- :   Rendered foods/index.html.erb within layouts/application (2.5ms)
I, [2015-03-22T11:31:49.653475 #25012]  INFO -- : Completed 200 OK in 5ms (Views: 3.4ms | ActiveRecord: 0.6ms)
D, [2015-03-24T00:08:13.314031 #28981] DEBUG -- :   ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
D, [2015-03-24T00:11:21.832413 #28999] DEBUG -- :   ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"

实际上,说实话,我甚至不知道我的服务器是否在生产中运行。日志中的时间似乎与我当地时间或我发送的页面请求(例如删除)相匹配。如何查看我所处的环境? (即使我在笔记本电脑上本地启动生产服务器,问题仍然存在)

我在Nginx,Unicorn,Rails 4.2和Ruby 2.1.3上使用DigitalOcean VPS

1 个答案:

答案 0 :(得分:0)

application.rb 中,添加

 config.time_zone = 'Eastern Time (US & Canada)'
 config.active_record.default_timezone = 'Eastern Time (US & Canada)'

替换东部时间(美国和加拿大)'和东部时间(美国和加拿大)'正常。

来源:How to change default timezone for Active Record in Rails?