I have a callback URL that is outlined in the MessagesController like so:
def message_create
message = Message.new( :message => params[:PAYLOAD],
:recipient => params[:DEST_ADDR],
:api_message_id => params[:MSG_ID],
:from => params[:SRC_ADDR],
:api_timestamp => params[:DATETIME],
:network => params[:NETWORK],
:origin => "sms")
message.save
redirect_to message
end
When I run my app locally this callback URL works just fine:
http://localhost:3000/message_create?PAYLOAD=asdfasdf&DEST_ADDR=234523&MSG_ID=23452345&SRC_ADDR=24345234234&DATETIME=20110915130534&NETWORK=blah
However, when I push the app to heroku and enter the same callback URL:
http://myapp.heroku.com/message_create?PAYLOAD=asdfasdf&DEST_ADDR=234523&MSG_ID=23452345&SRC_ADDR=24345234234&DATETIME=20110915130534&NETWORK=blah
It just gives me an error. I've looked into whether it's due to the:
before_filter :authenticate
line in my controller but even when that's commented out the data just won't submit to the remote DB. Your thoughts and experience are very-much appreciated.
UPDATE:
Just worked out how to access the full logs on Heroku. Looks like the issue might be to do with integer's not being large enough in Heroku by default:
2011-09-15T13:25:28+00:00 app[web.1]: Started GET "/message_create?PAYLOAD=asdfasdf&DEST_ADDR=234523&MSG_ID=23452345&SRC_ADDR=24345234234&DATETIME=20110915130534&NETWORK=blah" for 80.46.10.63 at 2011-09-15 06:25:28 -0700
2011-09-15T13:25:28+00:00 app[web.1]: Processing by MessagesController#message_create as HTML
2011-09-15T13:25:28+00:00 app[web.1]: Parameters: {"PAYLOAD"=>"asdfasdf", "DEST_ADDR"=>"234523", "MSG_ID"=>"23452345", "SRC_ADDR"=>"24345234234", "DATETIME"=>"20110915130534", "NETWORK"=>"blah"}
2011-09-15T13:25:28+00:00 app[web.1]: Completed in 10ms
2011-09-15T13:25:28+00:00 app[web.1]:
2011-09-15T13:25:28+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR: integer out of range
2011-09-15T13:25:28+00:00 app[web.1]: : INSERT INTO "messages" ("message", "created_at", "updated_at", "recipient", "api_message_id", "from", "origin", "timestamps", "user_id", "status", "api_timestamp", "network", "group_id") VALUES ('asdfasdf', '2011-09-15 13:25:28.650894', '2011-09-15 13:25:28.650894', 234523, 23452345, 24345234234, 'sms', NULL, NULL, NULL, '2011-09-15 13:05:34.000000', 'blah', NULL) RETURNING "id"):
2011-09-15T13:25:28+00:00 app[web.1]: app/controllers/messages_controller.rb:48:in `message_create'
2011-09-15T13:25:28+00:00 app[web.1]:
2011-09-15T13:25:28+00:00 app[web.1]:
2011-09-15T13:25:28+00:00 heroku[router]: GET www.myherokuapp.com/message_create dyno=web.1 queue=0 wait=0ms servic开发者_开发知识库e=14ms status=500 bytes=728
2011-09-15T13:25:28+00:00 heroku[nginx]: 80.46.10.63 - - [15/Sep/2011:06:25:28 -0700] "GET /message_create?PAYLOAD=asdfasdf&DEST_ADDR=234523&MSG_ID=23452345&SRC_ADDR=24345234234&DATETIME=20110915130534&NETWORK=blah HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.12 Safari/535.2" www.myherokuapp.com
Yes it seems like a data type error, what data types did you set for your fields on the messages table migration?
精彩评论