FYI – Ruby 1.9.1p243 and passenger 2.2.x not compatible

I tweeted this about two months ago, and since then I’ve talked to at least two people who have hit this same issue. I’m hoping google will index this and help any pour soul out there who takes the time to build or install ruby 1.9.1p243 and try to make it work with passenger 2.2.x – DONT TRY. I’m currently running ruby 1.9.1p129 with passenger 2.2.x without issue. So here it is:

Warning
Wary soul – go back – or move foward, but p243 will only claim hours of your life!

Flex Scroll Bars expected on child hbox – but on application instead?

I wrestled with this for a few days so I’m posting it here in hopes that it will help someone.  For whatever reason I had a really difficult time finding out the solution – to something that should have been very basic.  Here is a sample application where one would expect that the scroll bars would appear on the child mx:HBox:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:mx="library://ns.adobe.com/flex/halo"  layout="vertical"
                    minWidth="800"
                    minHeight="600">
     <fx:Script>
          <![CDATA[
               [Bindable]
               private var dp:Array = new Array(30);

          ]]>
     </fx:Script>
     <mx:HDividedBox width="100%" height="100%">
          <mx:Panel width="15%" height="100%">
               <mx:Label text="left"/>
          </mx:Panel>
          <mx:Box id="content" width="85%" height="100%" verticalScrollPolicy="auto" horizontalScrollPolicy="auto" >
               <mx:Repeater dataProvider="{dp}">
                    <mx:Label text="hello!" />
               </mx:Repeater>
          </mx:Box>
     </mx:HDividedBox>
</mx:Application>

I would have expected the HBox#content to have scroll bars, instead the scroll bars show up on the main application – why I have not figured out. However the solution (hack?) is to simply wrap the HBox#content in a mx:Canvas tag and put the width, height, and scrollbar settings there. Here is my solution (Let me know if you have a beter one!) :


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:mx="library://ns.adobe.com/flex/halo"  layout="vertical"
                    minWidth="800"
                    minHeight="600">
     <fx:Script>
          <![CDATA[
               [Bindable]
               private var dp:Array = new Array(30);

          ]]>
     </fx:Script>
     <mx:HDividedBox width="100%" height="100%">
          <mx:Panel width="15%" height="100%">
               <mx:Label text="left"/>
          </mx:Panel>
          <mx:Canvas width="85%" height="100%" verticalScrollPolicy="auto" horizontalScrollPolicy="auto" >
           <mx:Box id="content" >
               <mx:Repeater dataProvider="{dp}">
                    <mx:Label text="hello!" />
               </mx:Repeater>
          </mx:Box>
       </mx:Canvas>
     </mx:HDividedBox>
</mx:Application>

Webrick serving Rails 2.3.x over SSL

Just a couple days ago, I encountered an issue with having to serve a rails app over SSL from a local development environment.  Unfortunately the localhost was a windows machine, so using passenger wasn’t much of a choice.  I found several good articles talking about how to do this, however they didn’t work for me.  The one that got me the closeset was from a post at zunisoft.com (thanks Keith!).

I believe the issue I had was that the articles I was referencing were nearly a year old, and probably used an older version of rails.  I took a look at the server script that others proposed, vs the latest server.rb file (and hence rails’ server command.rb file) that is used in 2.3.x rails applications; and I believe the difference comes down to the changes in rails’ underpinnings to being rack based and how the webrick server & rails envirionment is setup and configured.

I first cracked open the ‘script/console.rb’  file from my app:


#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'

Turns out that, it isn’t too helpful, as the bulk of the logic exists somewhere else. Turns out if you freeze your rails gems, it’s in: ‘vendor/rails/railties/lib/commands/server.rb’. If you don’t freeze your gems, it’ll be in: $GEMS_HOME/gems/rails-2.3.x/lib/commands. This file’s a bit large to post here, but for discussion’s sake here’s a link to it on github.

After reviewing the file, I found I needed to add values into the options hash, but there didn’t seem an easy way to make that happen.  Since I was short on time, I took the path of least resistance 🙂 – I copied commands/server.rb and created a file in scirpts/ssl_server.rb.  For reference, here is a copy of the ssl_server script file I am running.

There are three notable changes I made:

  • Modified port to be 443 (to simplify testing)
  • Added options values for SSLEnable, SSLVerifyClient, SSLCertName
  • Removed block that determines server and forces the use of webrick

One last thing to note, in our scenario we needed to have mixed traffic over both 80 and 443.  In order to accomplish this, I borrowed a suggestion from the 81electric blog, and ran both the ssl_server and standard server scripts at the same time – maybe not elegant, but simple!