0

After tons of first-timer headache, I finally got my website deployed online, yay! :)

I can view the website just fine, but I cannot create/edit or delete any records. My research tells me that it has something to do with javascript handling the create/update/destroy requests, but I cannot find a solution. Maybe its not even related to javascript.

The error message given says "We're sorry, but something went wrong." check the logs.

My production log says:

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"

Actually, in all honesty I don't even know if my server is running in production. The time in the logs don't seem to match my local time or the page requests I send (eg. delete). How do I check what environment I am in? (The problem persists even when I start a production server locally on my laptop)

I am using DigitalOcean VPS with Nginx, Unicorn, Rails 4.2 and Ruby 2.1.3

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
nvrpicurnose
  • 677
  • 2
  • 6
  • 17
  • (1) What time zone is your server in? Is there a chance this is just a timezone offset mistake? (2) I only see a GET request. Doesn't look like you're calling any actions that would update/create/delete any data. – jefflunt Mar 24 '15 at 00:57
  • I tried to delete a record, which gave me the error. The delete does not pop up in the logs, which leads me to believe its not even in the environment. – nvrpicurnose Mar 24 '15 at 01:13
  • Okay. Sounds like you're right about it being the wrong environment. Check the unicorn config, and try to find out which environment is being invoked (and logged from) in the log file you're looking at. If you're on the production server then the unicorn config might tell you where the production log file is being written, and (maybe?) it's not the one you're looking at. Then again, maybe you're on the wrong server? – jefflunt Mar 24 '15 at 01:23
  • There is no config file inside /config/unicorn.rb I checked the other config files but they don't have an option to set the environment. So far I've been setting the environmensudt via terminal using: $sudo service unicorn restart RAILS_ENV=production Is that even valid? – nvrpicurnose Mar 24 '15 at 01:44

1 Answers1

0

In application.rb, add

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

Replace 'Eastern Time (US & Canada)' and ''Eastern Time (US & Canada)' properly.

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

Community
  • 1
  • 1