Rails, Rspec and Capybara Connection Reset Error

If you happen to be seeing a Connection Reset by Peer error in one of your rspec acceptance tests using capybara, chances are you have your config.action_dispatch.show_exceptions set to false for your test environment.

Just thought I’d share as it took me a bit of googling to figure this out. Hoping I could help out the next person!

# Raise exceptions instead of rendering exception templates
- config.action_dispatch.show_exceptions = false
+ config.action_dispatch.show_exceptions = true

Chrome table cells not word wrapping correctly

In working on my recently released vain routes gem, I came across a frustrating issue getting the table in chrome to word wrap the data in the cells.  It was working flawlessly in Firefox and even IE but despite trying several different attempts to make it work; Chrome kept overlapping the text between cells.

I tried several different iterations including explicitly defining  the width of the table cells and the table itself.  I even set the overflow property to hidden, something I thought would have at least constrained the text from overflowing.

To keep things short, this is what I needed to do

  1. Keep the explicit width defined on the table
  2. Set the css table-layout on the table as:
  3. Set the css word-wrap property on the td element as:

As a final note, I initially tried using the css word-wrap property for a col element, but for whatever reason it did not take.

Hopefully I’ve helped someone else out there who may be having a similar problem.

Vain Routes – A Rails Engine

You didn’t invest all that time into creating your beautiful restful routes only to have them displayed in a console window, did you?

Introducing ‘Vain Routes’ – a rails engine that enables you to view your routes directly from your browser, sort them, and even filter them! While the command line may helpful, it isn’t as pretty as this!


  • Clean User Inteface to view your routes as html
  • Sort your routes by verb, path, controller or action
    Sort Routes
  • Filter routes by keywords
    Filter Routes
  • A rails 3 engine which is installed and running in under a minute!

Update your Gemfile:

Launch your Server

Open your browser to: http://localhost:3000/vain/routes

ruby-oci8 & SELinux

LoadError: /opt/oracle/instantclient_10_2/libnnz10.so: cannot restore segment prot after reloc: Permission denied - /usr/local/ruby192p0/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.3/lib/oci8lib_191.so
from :29:in require'
from :29:in
from /usr/local/ruby192p0/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.0.3/lib/oci8.rb:23:in '
from :33:in
from :33:in rescue in require'
from :29:in
from (irb):1
from /usr/local/ruby/bin/irb:12:in `'

/libnnz10.so: cannot restore segment prot after

If you encounter an error like above, the problem very well could be the SELinux (Security Enhanced Linux) conf setting.   We ran into this issue trying to use ruby-oci8 in our rails application.  It was working on one CentOS VM we built, but not on another coworkers.  After painstakingly taking things apart, it turns out the difference between the two virtual machine instances was that the ‘getenforce’ command returned ‘Disabled’ on one and ‘Enforcing’ on another.

A quick ‘setenforce 0’ will enable you to test out if this fixes your issue.  However be warned that to disable it so that it doesn’t come back after restarting, you must modify the ‘/etc/selinux/config’ to disable it permanently.   GL!

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:

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:

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!) :

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:

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!

Extending a Plugin within rails

Image by

Image by kqedquest

Have you ever wanted to add a method to a class that belonged to a plugin? Well the other day while I was working on articlips.com, I found myself in that position. I am using the acts_as_taggable_on plugin and wanted to memoize a call I was making a lot in various outputs:
<%= tag.name.titleize =>
This is one of those problems I could have solved several ways:

  • Focus on normalizing the data on input
  • Use a helper to accomplish the same goal
  • Cache the page/partial output
  • Not worry about it at all, as this is probably not worth the performance gains per effort invested (at the moment I’m sure there’s plenty more I can optimize)

However it was more out of curiosity that I pursued solving it the way that I initially set out to do.   My first attempt was simply creating a class of the same name in my models folder, but that didn’t have the effect I wanted as (I believe) because the way rails loads classes, it overwrote the class definition instead of adding to it.

At this point I knew there had to be a better way than just modifying the code in the vendor/plugins folder.   Turns out the solution is to add the class/file in the initializers folder as that is the correct time to augment the class during rails initialization.  In hindsight,  pretty obvious.  However since I’m not familiar with the underlying mechanisms of rails as much as I’d like to be, I think I’ve generally overlooked the initializers folder.