0

I'm developing a Rails app that works fine in development. However when I deploy to Heroku I run into issues. The app works fine up until I go to create a new user in which case I get "We're sorry, but something went wrong." I've tried dumping the database via pg:reset and migrating the database. Here is my logs heroku logs:

2012-04-06T06:09:14+00:00 app[web.1]:       - 45550
2012-04-06T06:09:14+00:00 app[web.1]:       - 45553
2012-04-06T06:09:14+00:00 app[web.1]:       - 45554
2012-04-06T06:09:14+00:00 app[web.1]:       - 45557
2012-04-06T06:09:14+00:00 app[web.1]:       - 45560
2012-04-06T06:09:14+00:00 app[web.1]:       - 45561
2012-04-06T06:09:14+00:00 app[web.1]:       - 45563
2012-04-06T06:09:14+00:00 app[web.1]:       - 45564
2012-04-06T06:09:14+00:00 app[web.1]:       - 45562
2012-04-06T06:09:14+00:00 app[web.1]:       - 45565
2012-04-06T06:09:14+00:00 app[web.1]:       - 45566
2012-04-06T06:09:14+00:00 app[web.1]:       - 45569
2012-04-06T06:09:14+00:00 app[web.1]:       - 53056
2012-04-06T06:09:14+00:00 app[web.1]:       - 57421
2012-04-06T06:09:14+00:00 app[web.1]:       - 58512
2012-04-06T06:09:14+00:00 app[web.1]:       - 58065
2012-04-06T06:09:14+00:00 app[web.1]:       - 58521
2012-04-06T06:09:14+00:00 app[web.1]:       - 58523
2012-04-06T06:09:14+00:00 app[web.1]:       - 58525
2012-04-06T06:09:14+00:00 app[web.1]:       - 58528
2012-04-06T06:09:14+00:00 app[web.1]:       - 62044
2012-04-06T06:09:14+00:00 app[web.1]:       - 62045
2012-04-06T06:09:14+00:00 app[web.1]:       - 62049
2012-04-06T06:09:14+00:00 app[web.1]:       - 62050
2012-04-06T06:09:14+00:00 app[web.1]:       - 64054
2012-04-06T06:09:14+00:00 app[web.1]:       - 64358
2012-04-06T06:09:14+00:00 app[web.1]:       - 62051
2012-04-06T06:09:14+00:00 app[web.1]:       - 93741
2012-04-06T06:09:14+00:00 app[web.1]: ', "achievement_points" = 5090, "thumbnail" = 'kiljaeden/52/114968116-avatar.jpg', "last_modified" = 1332004740000, "stats" = '--- !ruby/object:OpenStruct 
2012-04-06T06:09:14+00:00 app[web.1]: modifiable: true
2012-04-06T06:09:14+00:00 app[web.1]: table: 
2012-04-06T06:09:14+00:00 app[web.1]:   :health: 133243
2012-04-06T06:09:14+00:00 app[web.1]:   :powerType: mana
2012-04-06T06:09:14+00:00 app[web.1]:   :power: 107618
2012-04-06T06:09:14+00:00 app[web.1]:   :agi: 58
2012-04-06T06:09:14+00:00 app[web.1]:   :sta: 6885
2012-04-06T06:09:14+00:00 app[web.1]:   :int: 6032
2012-04-06T06:09:14+00:00 app[web.1]:   :str: 53
2012-04-06T06:09:14+00:00 app[web.1]:   :spr: 411
2012-04-06T06:09:14+00:00 app[web.1]:   :attackPower: 43
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedAttackPower: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :mastery: 11.369031
2012-04-06T06:09:14+00:00 app[web.1]:   :masteryRating: 604
2012-04-06T06:09:14+00:00 app[web.1]:   :crit: 10.45436
2012-04-06T06:09:14+00:00 app[web.1]:   :critRating: 1203
2012-04-06T06:09:14+00:00 app[web.1]:   :hitRating: 1653
2012-04-06T06:09:14+00:00 app[web.1]:   :hasteRating: 2612
2012-04-06T06:09:14+00:00 app[web.1]:   :hitPercent: 14.762522
2012-04-06T06:09:14+00:00 app[web.1]:   :expertiseRating: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :spellPower: 8355
2012-04-06T06:09:14+00:00 app[web.1]:   :spellPen: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :spellCrit: 19.913286
2012-04-06T06:09:14+00:00 app[web.1]:   :spellCritRating: 1203
2012-04-06T06:09:14+00:00 app[web.1]:   :mana5: 1404.0
2012-04-06T06:09:14+00:00 app[web.1]:   :spellHitPercent: 17.13537
2012-04-06T06:09:14+00:00 app[web.1]:   :spellHitRating: 1653
2012-04-06T06:09:14+00:00 app[web.1]:   :mana5Combat: 869.0
2012-04-06T06:09:14+00:00 app[web.1]:   :armor: 9195
2012-04-06T06:09:14+00:00 app[web.1]:   :dodge: 3.652076
2012-04-06T06:09:14+00:00 app[web.1]:   :dodgeRating: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :parry: 0.0
2012-04-06T06:09:14+00:00 app[web.1]:   :parryRating: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :block: 0.0
2012-04-06T06:09:14+00:00 app[web.1]:   :mainHandDmgMin: 313.0
2012-04-06T06:09:14+00:00 app[web.1]:   :blockRating: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :resil: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :mainHandDmgMax: 579.0
2012-04-06T06:09:14+00:00 app[web.1]:   :mainHandSpeed: 1.329
2012-04-06T06:09:14+00:00 app[web.1]:   :mainHandDps: 335.91428
2012-04-06T06:09:14+00:00 app[web.1]:   :mainHandExpertise: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :offHandDmgMin: 0.0
2012-04-06T06:09:14+00:00 app[web.1]:   :offHandDmgMax: 0.0
2012-04-06T06:09:14+00:00 app[web.1]:   :offHandDps: 0.0
2012-04-06T06:09:14+00:00 app[web.1]:   :offHandSpeed: 1.661
2012-04-06T06:09:14+00:00 app[web.1]:   :offHandExpertise: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedDmgMin: 1581.0
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedDmgMax: 2937.0
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedDps: 1511.1627
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedSpeed: 1.495
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedCrit: 10.45436
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedCritRating: 1203
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedHitRating: 1653
2012-04-06T06:09:14+00:00 app[web.1]:   :rangedHitPercent: 14.762522
2012-04-06T06:09:14+00:00 app[web.1]: ', "appearance" = '--- !ruby/object:OpenStruct 
2012-04-06T06:09:14+00:00 app[web.1]: modifiable: true
2012-04-06T06:09:14+00:00 app[web.1]: table: 
2012-04-06T06:09:14+00:00 app[web.1]:   :faceVariation: 1
2012-04-06T06:09:14+00:00 app[web.1]:   :skinColor: 6
2012-04-06T06:09:14+00:00 app[web.1]:   :hairVariation: 13
2012-04-06T06:09:14+00:00 app[web.1]:   :hairColor: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :showHelm: 0
2012-04-06T06:09:14+00:00 app[web.1]:   :featureVariation: 1
2012-04-06T06:09:14+00:00 app[web.1]:   :showCloak: 0
2012-04-06T06:09:14+00:00 app[web.1]: ', "updated_at" = '2012-04-06 06:09:14.199366', "progression" = '--- 
2012-04-06T06:09:14+00:00 app[web.1]: ' WHERE "wow_characters"."id" = 1):
2012-04-06T06:09:14+00:00 app[web.1]:   app/models/user.rb:66:in `fetch_character_info'
2012-04-06T06:09:14+00:00 app[web.1]:   app/controllers/users_controller.rb:25:in `create'
2012-04-06T06:09:14+00:00 app[web.1]: 
2012-04-06T06:09:14+00:00 app[web.1]: 
2012-04-06T06:09:14+00:00 app[web.1]: cache: [POST /users] invalidate, pass

Anyone have any ideas what would cause this? Very confusing that it works in my dev environment but not in produciton on Heroku.

WowCharacter model:

# == Schema Information
#
# Table name: wow_characters
#
#  id                 :integer         not null, primary key
#  user_id            :integer
#  realm              :string(255)
#  name               :string(255)
#  level              :integer
#  race               :string(255)
#  class_id           :string(255)
#  gender             :integer
#  guild              :text
#  talents            :text
#  items              :text
#  professions        :text
#  progression        :text
#  achievement_points :integer
#  thumbnail          :string(255)
#  last_modified      :datetime
#  created_at         :datetime        not null
#  updated_at         :datetime        not null
#  stats              :text
#  appearance         :text
#

class WowCharacter < ActiveRecord::Base

  # Set accessible fields
  attr_accessible :user_id, :realm, :name, :level, :race, :class_id, :gender, :guild, :stats,
                  :talents, :items, :professions, :appearance, :achievement_points, :thumbnail, 
                  :last_modified, :wow_character

  serialize :guild
  serialize :talents
  serialize :items 
  serialize :professions
  serialize :progression
  serialize :stats
  serialize :appearance

  # Create reference to User model
  belongs_to :user
end

Not sure if this helps, but after doing some more testing I can confirm that it stops on: app[web.1]: cache: [POST /users] invalidate, pass everytime. I figured this out by trailing the heroku logs.

4

1 に答える 1

1

私はこの問題を解決することができました。Heroku でのセットアップと一致するように、開発用 ENV で SQLite3 を Postgre に置き換えることにしました。これを行った後、問題をより簡単にデバッグすることができ、最終的には型キャストの問題でした。:last_modifiedフィールドはありますが、:datetimeプッシュしていた値は UNIX タイムスタンプであり、Postgre でエラーをスローしていました。

「タイムゾーンなしでタイムスタンプを入力しますが、式は bigint 型です」

UNIX タイムスタンプで変換を実行することで、問題を修正できました。

:last_modified = Time.at(timestamp)
于 2012-04-07T02:34:05.260 に答える