Saturday, March 12, 2011

Be careful writing hooks to Rack layer (middle ware layer) in Rails

I've got this error from a Rails project:

ERROR NoMethodError: private method `split' called for 0:Fixnum


Following the link below gave me some clues:
http://rack.lighthouseapp.com/projects/22435/tickets/52-read-error-nomethoderror-private-method-split-called-for-0fixnum


1. something's wrong in Rack layer
2. someone wrote incorrect code that hooked to Rack layer 

Case #1: rarely happened
Case #2: may be 

I did some search and found this code in authentication module:
response.headers["Expires"] = 0

This must be the cause of the error. 

Though the correct code is just: 
response.headers["Expires"] = "0"

it still took me over a day to find out and fix that bug!!! 

Simple but not simple!


1 comment:

Maneesh Kalra said...
This comment has been removed by the author.