Posts Tagged ‘Ruby on Rails’
Cookies in iFrames: how bashing my head on the table made them work in Internet Explorer
Posted by Giovanni Intini | Filed under Rails, Random Stuff, Ruby
While working on our TTGPassport our valiant team hit a wall that most programmers hit sooner or later when working with iframes: cookies won’t work with Internet Explorer, and you will lose your session.
The internet is full or remedies for this unnerving problem, most of them revolving on pseudo-magically setting the P3P header. I don’t believe in pseudo-magic, so I kept googling for answers, until I found this informing post.
I diligently ran through the suggestions but we had random session losses, with no reasonable explanation. We were setting our P3P header in a before filter (Rails application), like this:
class ApplicationController < ActionController::Base before_filter :set_p3p def set_p3p response.headers["P3P"]='CP="NOI DSP LAW NID"' end end
Fearing Rails could be the culprit I changed our Apache configuration to set the header on every request, using the following directive:
Header set P3P "CP=\"NOI DSP LAW NID\""
Unfortunately even bypassing Rails didn’t help. I was even unsure of why sometimes it worked and sometimes it didn’t (basically when explorer shows the evil red eye on the bottom of the page it means it’s blocking your cookies).
I started playing around with Firebug to see what could be the problem, and finally a little lightbulb lit on top of my head: the pages that broke the session didn’t have the P3P header, and instead they had an ETag header. That means something was adding the ETag and that the browser recalled the content of the page from its cache, thus bypassing P3P and upsetting explorer. I disabled ETags in Apache:
Header unset ETag FileETag None
Guess what? It didn’t work. Something was still setting the ETag header and bypassing my beloved and much needed P3P. The only culprit could be Ruby on Rails. I googled some more but nothing really told me how to disable ETags so I had to resort to some monkey patching:
module ActionController class Request def etag_matches?(etag) false end end class Response def etag? true end end end
I asked our strong, silent project manager to test it because I was crossing my fingers too hard, and, finally, it worked, no ETags and our P3P header where we expected it.
I hope you are reading this article because you had the same problem we had, and I hope it will help you as it helped us!
The importance of being up-to-date
Posted by Giovanni Intini | Filed under Business, mikamai, Rails, Ruby on Rails
Since I started working in the web development business the release of Rails 3 has been the first time I really felt I had to understand what was going on because otherwise I would be left behind.
There were simpler times where just reading the feeds of the most important blogs allowed me to be up-to-date, but either I’m getting old or the information has become too fractioned, because this time the only reason for me (and everyone in MIKAMAI) to get started with Rails 3 was to resume a practice that unfortunately we left behind in the past year: the internal presentations.
Starting last thursday, and hopefully never stopping, thursday afternoons aren’t about working for others, but are about everyone sharing his knoweledge with the others.
Last thursday was obviously all about Rails 3, so a couple of us connected their macs to the big screen and demoed new features of Rails 3.
It was nice, interesting questions were asked during the demos, and the overall mood was pretty good. I look forward to the next session.
Continous Integration with RunCodeRun
Posted by Giovanni Intini | Filed under mikamai, Ruby, Ruby on Rails
Last thursday MIKAMAI hosted a Ruby Social Club meeting. Here’s the slides for my presentation.