I suggest you just use key.to_s as a quick workaround.
The cause of your problem may be that some version of a component is different between your test server and the production server. If your tests pass and your production environment fails, this is a very bad situation.
You should compare the versions of ruby ββand all the gems you use. If you are using a "bundler" then a "list of packages" gives a good summary.
If you find out that all versions are the same ... Well, we will look for another reason.
Update
It seems that the problem is not caused by version differences, but by unexpected data in flash memory, which, obviously, in a production environment may differ from testing.
I suggest changing the myModelFlash method a myModelFlash .
def myModelFlash( key ) if m = /^_mymodel_(.*)/.match(key.to_s) return m[1] end end
The flash may contain different keys, some of them can be characters or really any, so you should be prepared to handle all of them.
Converting the key parameter using .to_s should be a safe choice, but if you are sure to always set the flash keys (I mean the keys related to this _mymodel problem) as strings, you can change the first line of this method :
def myModelFlash( key ) if key.is_a?(String) && m = /^_mymodel_(.*)/.match(key.to_s) return m[1] end end
And in your test, add a few more keys to your flash, and then check how the action processes them.
source share